From 4af60254564bdab7deaeb2ee5006d9c87a16edb4 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 10 Feb 2018 22:49:47 +0000 Subject: mpostinl (10feb18) git-svn-id: svn://tug.org/texlive/trunk@46587 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/mpostinl/README.txt | 2 +- Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex | 3 +- Master/texmf-dist/doc/latex/mpostinl/mpostinl.pdf | Bin 329122 -> 331717 bytes .../texmf-dist/source/latex/mpostinl/mpostinl.dtx | 142 +++++++++++++++++---- Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty | 76 ++++++++--- 5 files changed, 179 insertions(+), 44 deletions(-) diff --git a/Master/texmf-dist/doc/latex/mpostinl/README.txt b/Master/texmf-dist/doc/latex/mpostinl/README.txt index fbe4d635f60..bfc76cc91b5 100644 --- a/Master/texmf-dist/doc/latex/mpostinl/README.txt +++ b/Master/texmf-dist/doc/latex/mpostinl/README.txt @@ -1,4 +1,4 @@ -mpostinl v1.21 +mpostinl v1.3 Copyright 2010-2018 Niklas Beisert mpostinl is a LaTeX2e package diff --git a/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex b/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex index cec96fc5438..b30c26524a9 100644 --- a/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex +++ b/Master/texmf-dist/doc/latex/mpostinl/mpinlsmp.tex @@ -17,7 +17,7 @@ %% version 2005/12/01 or later. %% \NeedsTeXFormat{LaTeX2e}[1996/12/01] -\ProvidesFile{mpinlsmp.tex}[2018/01/17 v1.21 sample for mpostinl] +\ProvidesFile{mpinlsmp.tex}[2018/02/09 v1.3 sample for mpostinl] \documentclass[12pt,a4paper]{article} \parindent0pt @@ -36,6 +36,7 @@ %% some sample package options: %% \mpostsetup{write=false} %% \mpostsetup{compile=false} +\mpostsetup{checksum} \mpostsetup{now} %% \mpostsetup{nowall} \mpostsetup{lineno} diff --git a/Master/texmf-dist/doc/latex/mpostinl/mpostinl.pdf b/Master/texmf-dist/doc/latex/mpostinl/mpostinl.pdf index d16bdbd05a4..9101df2924c 100644 Binary files a/Master/texmf-dist/doc/latex/mpostinl/mpostinl.pdf and b/Master/texmf-dist/doc/latex/mpostinl/mpostinl.pdf differ diff --git a/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx b/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx index 8d3db2a20dc..217badda9c9 100644 --- a/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx +++ b/Master/texmf-dist/source/latex/mpostinl/mpostinl.dtx @@ -18,10 +18,10 @@ % and the derived files mpostinl.sty and mpinlsmp.tex % %\NeedsTeXFormat{LaTeX2e}[1996/12/01] -%\ProvidesPackage{mpostinl}[2018/01/17 v1.21 metapost inline figures] -%\ProvidesFile{mpinlsmp.tex}[2018/01/17 v1.21 sample for mpostinl] +%\ProvidesPackage{mpostinl}[2018/02/09 v1.3 metapost inline figures] +%\ProvidesFile{mpinlsmp.tex}[2018/02/09 v1.3 sample for mpostinl] %<*driver> -%\ProvidesFile{mpostinl.drv}[2018/01/17 v1.21 mpostinl reference manual file] +%\ProvidesFile{mpostinl.drv}[2018/02/09 v1.3 mpostinl reference manual file] \PassOptionsToClass{10pt,a4paper}{article} \documentclass{ltxdoc} @@ -62,7 +62,7 @@ {\texttt{nbeisert@itp.phys.ethz.ch}}} \hypersetup{pdfauthor={Niklas Beisert}} \hypersetup{pdfsubject={Manual for the LaTeX2e Package mpostinl}} -\date{17 January 2018, \textsf{v1.21}} +\date{9 February 2018, \textsf{v1.3}} \maketitle \begin{abstract}\noindent @@ -347,7 +347,7 @@ Either avoid leading empty lines and empty bodies or use empty optional arguments: |\begin{mpostfig}[]|. \item -Lines starting with a single `|%|' are ignored and +Lines starting with a single `|%|' are ignored and do not appear in the metapost file. Double `|%%|' or leading spaces preserve comments in the metapost file. @@ -458,6 +458,16 @@ Requires shell escapes to work properly. Enable/disable secondary metapost compilation. Some metapost files may require this to produce the intended output. +\item |clean|[|=true|$\vert$|false|] +(no value implies |true|, initially set to |true|) -- +Enable/disable cleaning of figure files prior to compilation. +A dummy figure will be shown in case metapost cannot generate a figure. + +\item |checksum|[|=true|$\vert$|false|] +(no value implies |true|, initially set to |false|) -- +Enable/disable update detection. +Compiles figures only if the metapost code has changed. + \item |fonts|[|=true|$\vert$|false|] (no value implies |true|, initially set to |false|) -- Enable/disable embedding of fonts in metapost figures @@ -675,11 +685,19 @@ In particular, this may be desirable if the \LaTeX{} source is uploaded to a repository or passed on to a publisher. -By default the package checks whether the generated files +The package can check whether the generated files change with respect to the previous \LaTeX{} pass, and only modified files are compiled thereupon. -This check can be disabled by setting the option -|checksum| to |false|, in which case all files are compiled. +This check can be enabled by setting the option +|checksum| to |true|. +Note that under some conditions +(in particular, if the previous \LaTeX{} pass +produced compile errors), +figures may not get compiled even though the source changed. +In that case you can trigger compilation +by deleting the generated metapost source or figures +or by introducing further changes to the metapost code. +By default all files are compiled. When the metapost file compiles with errors, one can inspect the generated metapost file. @@ -1175,11 +1193,26 @@ to the usual \TeX{} philosophy. %\item %an environment to pass tex commands to mpost and also compile them locally %probably have to write to file and subsequently input the file +%perhaps could use \scantokens! +%\item +%improve detection of changed figure files? +%allow to declare extra include files for update detection \end{itemize} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection{Revision History} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\paragraph{v1.3:} 2018/02/09 + +\begin{itemize} +\item +new |clean| option to initialise figure files +with dummy figures to show \MP{} compiler errors +\item +|checksum| behaviour improved +\end{itemize} + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \paragraph{v1.21:} 2018/01/17 @@ -1344,6 +1377,7 @@ basic functionality %% some sample package options: %% \mpostsetup{write=false} %% \mpostsetup{compile=false} +\mpostsetup{checksum} \mpostsetup{now} %% \mpostsetup{nowall} \mpostsetup{lineno} @@ -1839,6 +1873,8 @@ filename: \mpostgetname{sec8} \newif\ifmpi@write\mpi@writetrue \newif\ifmpi@compile\mpi@compiletrue \newif\ifmpi@twice\mpi@twicefalse +\newif\ifmpi@clean\mpi@cleantrue +\newif\ifmpi@checksum\mpi@checksumfalse \newif\ifmpi@lineno\mpi@linenofalse \newif\ifmpi@labelnames\mpi@labelnamesfalse \newif\ifmpi@nowactive\mpi@nowactivefalse @@ -1846,7 +1882,6 @@ filename: \mpostgetname{sec8} \newif\ifmpi@nowkeep\mpi@nowkeepfalse \newif\ifmpi@include\mpi@includefalse \newif\ifmpi@defglobal\mpi@defglobalfalse -\newif\ifmpi@checksum\mpi@checksumtrue % \end{macrocode} % \begin{macro}{\mpi@mpostmem} @@ -1889,6 +1924,7 @@ filename: \mpostgetname{sec8} \define@key{\mpi@group}{latex}[true]{\csname mpi@latex#1\endcsname} \define@key{\mpi@group}{compile}[true]{\csname mpi@compile#1\endcsname} \define@key{\mpi@group}{twice}[true]{\csname mpi@twice#1\endcsname} +\define@key{\mpi@group}{clean}[true]{\csname mpi@clean#1\endcsname} \define@key{\mpi@group}{checksum}[true]{\csname mpi@checksum#1\endcsname} \define@key{\mpi@group}{fonts}[true]{\csname mpi@fonts#1\endcsname} \define@key{\mpi@group}{prologues}[]{\def\mpi@prologues{#1}} @@ -2288,13 +2324,12 @@ filename: \mpostgetname{sec8} % \begin{macro}{\mpi@getchecksum} % Compute the MD5 checksum for a metapost file and store in macro: % \begin{macrocode} -\newcommand{\mpi@getchecksum}[2]{% - \IfFileExists{#2}{\xdef#1{\pdfmdfivesum file{#2}}}{\global\let#1=\@undefined}% +\newcommand{\mpi@getchecksum}[3]{% + \IfFileExists{#3}{#1\edef#2{\pdfmdfivesum file{#3}}}{#1\let#2=\@undefined}% } % \end{macrocode} % \end{macro} - % \begin{macro}{\mpi@startfile} % Start a new file if not already open: % \begin{macrocode} @@ -2310,13 +2345,16 @@ filename: \mpostgetname{sec8} % Compute checksum of old file: % \begin{macrocode} \ifmpi@checksum\ifmpi@inclmod\else% - \mpi@getchecksum{\mpi@checksum@before}{\mpostfilename.mp}% + \mpi@getchecksum{\global}{\mpi@checksum@before}{\mpostfilename.mp}% \fi\fi% + \ifmpi@checksum\global\mpi@filemodfalse\else\global\mpi@filemodtrue\fi% + \ifmpi@inclmod\global\mpi@filemodtrue\fi% % \end{macrocode} % Open file for writing, prepare and write header to file: % \begin{macrocode} \global\mpi@infiletrue% \global\mpi@showinfilefalse% + \gdef\mpi@filelist{}% \ifmpi@write\immediate\openout\mpi@out\mpostfilename.mp\fi% \mpi@clearbuf% \mpi@beginfile% @@ -2405,6 +2443,40 @@ filename: \mpostgetname{sec8} % \end{macrocode} % \end{macro} +% \begin{macro}{\mpi@cleanfile} +% Write a mps file containing a plain cross: +% \begin{macrocode} +\newcommand{\mpi@cleanfile}[1]{% + \immediate\openout\mpi@outnow#1% + \immediate\write\mpi@outnow{% + \@percentchar!PS-Adobe-3.0 EPSF-3.0^^J% + \@percentchar\@percentchar Title: missing figure file^^J% + \@percentchar\@percentchar Creator: mpostinl.sty^^J% + \@percentchar\@percentchar BoundingBox: -36 -22 36 22^^J% + \@percentchar\@percentchar EndComments^^J% + \@percentchar\@percentchar Page: 1 1^^J% + 0 setgray 0 1.5 dtransform truncate idtransform setlinewidth pop^^J% + [] 0 setdash 1 setlinecap 1 setlinejoin 10 setmiterlimit^^J% + newpath -35 21 moveto 35 -21 lineto stroke^^J% + newpath -35 -21 moveto 35 21 lineto stroke^^J% + \@percentchar\@percentchar EOF}% + \immediate\closeout\mpi@outnow% +} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\mpi@cleanfiles} +% Clean all figure files prior to compilation: +% \begin{macrocode} +\newcommand{\mpi@cleanfiles}[1]{% + \begingroup\def\mpi@tmp{#1}% + \ifx\mpi@tmp\mpi@empty\else\def\mpi@tmp{\mpi@cleanfiles}% + \mpi@cleanfile{#1}\fi% + \expandafter\endgroup\mpi@tmp% +} +% \end{macrocode} +% \end{macro} + % \begin{macro}{\mpi@closefile} % Close the file, compile and reset: % \begin{macrocode} @@ -2427,21 +2499,20 @@ filename: \mpostgetname{sec8} % \end{macrocode} % Determine whether file has changed: % \begin{macrocode} - \mpi@filemodtrue% - \ifmpi@checksum\ifmpi@inclmod\else% - \mpi@getchecksum{\mpi@checksum@after}{\mpostfilename.mp}% - \ifx\mpi@checksum@before\mpi@checksum@after% - \mpi@filemodfalse% - \else% - \ifmpi@include\mpi@inclmodtrue\fi% - \fi% - \fi\fi% + \ifmpi@filemod\else% + \mpi@getchecksum{}{\mpi@checksum@after}{\mpostfilename.mp}% + \ifx\mpi@checksum@before\mpi@checksum@after\else\mpi@filemodtrue\fi% + \fi% + \ifmpi@include\ifmpi@filemod\global\mpi@inclmodtrue\fi\fi% % \end{macrocode} % Compile if file has changed and if it contains figures. % Activate warning if file has changed and figures were displayed % during composition: % \begin{macrocode} - \ifmpi@filemod\ifmpi@inbody\mpi@compile{\mpostfilename.mp}\fi\fi% + \ifmpi@filemod\ifmpi@inbody% + \ifmpi@clean\expandafter\mpi@cleanfiles\mpi@filelist{}\fi% + \mpi@compile{\mpostfilename.mp}% + \fi\fi% \ifmpi@filemod\ifmpi@showinfile\global\mpi@warnmodtrue\fi\fi% % \end{macrocode} % Reset variables: @@ -2482,6 +2553,7 @@ filename: \mpostgetname{sec8} \mpi@endfile% \immediate\write\mpi@outnow{\the\mpi@buf}% \immediate\closeout\mpi@outnow% + \ifmpi@clean\mpi@cleanfile{\mpi@figfile}\fi% \mpi@compile{\mpi@nowname.mp}% \fi\fi\fi% } @@ -2551,7 +2623,7 @@ filename: \mpostgetname{sec8} \mpi@addbuf{verbatimtex}% \fi% \mpi@verbatim% -}% +} % \end{macrocode} % Postprocessing; add `|etex|' if in \TeX{} mode, % add to appropriate buffer(s). @@ -2640,19 +2712,37 @@ filename: \mpostgetname{sec8} \mpi@putlineno% \mpi@beginfig{\mpi@figfile}% \mpi@verbatim% -}% +} % \end{macrocode} -% Postprocessing; end figure block, add to buffer, +% Postprocessing; end figure block, add to buffer, add file to list, % process immediately if desired: % \begin{macrocode} {% \mpi@endverbatim% \mpi@endfig% \mpi@writebuf% + \xdef\mpi@filelist{\mpi@filelist{\mpi@figfile}}% \ifmpi@now% \mpi@processnow% \fi% % \end{macrocode} +% Force compile if output file does not exist, is empty or equals dummy figure: +% \begin{macrocode} + \ifmpi@filemod\else% + \mpi@getchecksum{}{\mpi@tmpa}{\mpi@figfile}% + \ifdefined\mpi@tmpa% + \edef\mpi@tmpa{\scantokens\expandafter{\mpi@tmpa\noexpand}}% + \def\mpi@tmpb{965DFFE32ABB43CC14C58E254B4D660E}% + \ifx\mpi@tmpa\mpi@tmpb\global\mpi@filemodtrue\fi% + \def\mpi@tmpb{D78A5F2EE4B244260ECD6A0E89ADC9CE}% + \ifx\mpi@tmpa\mpi@tmpb\global\mpi@filemodtrue\fi% + \def\mpi@tmpb{D41D8CD98F00B204E9800998ECF8427E}% + \ifx\mpi@tmpa\mpi@tmpb\global\mpi@filemodtrue\fi% + \else% + \global\mpi@filemodtrue% + \fi + \fi% +% \end{macrocode} % Display figure. % Remember immediate display of figure unless processed immediately: % \begin{macrocode} diff --git a/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty b/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty index 7eec411d180..4064c4c7b48 100644 --- a/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty +++ b/Master/texmf-dist/tex/latex/mpostinl/mpostinl.sty @@ -17,7 +17,7 @@ %% version 2005/12/01 or later. %% \NeedsTeXFormat{LaTeX2e}[1996/12/01] -\ProvidesPackage{mpostinl}[2018/01/17 v1.21 metapost inline figures] +\ProvidesPackage{mpostinl}[2018/02/09 v1.3 metapost inline figures] \RequirePackage{verbatim} \RequirePackage{graphicx} @@ -38,6 +38,8 @@ \newif\ifmpi@write\mpi@writetrue \newif\ifmpi@compile\mpi@compiletrue \newif\ifmpi@twice\mpi@twicefalse +\newif\ifmpi@clean\mpi@cleantrue +\newif\ifmpi@checksum\mpi@checksumfalse \newif\ifmpi@lineno\mpi@linenofalse \newif\ifmpi@labelnames\mpi@labelnamesfalse \newif\ifmpi@nowactive\mpi@nowactivefalse @@ -45,7 +47,6 @@ \newif\ifmpi@nowkeep\mpi@nowkeepfalse \newif\ifmpi@include\mpi@includefalse \newif\ifmpi@defglobal\mpi@defglobalfalse -\newif\ifmpi@checksum\mpi@checksumtrue \def\mpi@mpostmem{} \def\mpi@mpostcompiler{} @@ -66,6 +67,7 @@ \define@key{\mpi@group}{latex}[true]{\csname mpi@latex#1\endcsname} \define@key{\mpi@group}{compile}[true]{\csname mpi@compile#1\endcsname} \define@key{\mpi@group}{twice}[true]{\csname mpi@twice#1\endcsname} +\define@key{\mpi@group}{clean}[true]{\csname mpi@clean#1\endcsname} \define@key{\mpi@group}{checksum}[true]{\csname mpi@checksum#1\endcsname} \define@key{\mpi@group}{fonts}[true]{\csname mpi@fonts#1\endcsname} \define@key{\mpi@group}{prologues}[]{\def\mpi@prologues{#1}} @@ -267,8 +269,8 @@ \fi% } -\newcommand{\mpi@getchecksum}[2]{% - \IfFileExists{#2}{\xdef#1{\pdfmdfivesum file{#2}}}{\global\let#1=\@undefined}% +\newcommand{\mpi@getchecksum}[3]{% + \IfFileExists{#3}{#1\edef#2{\pdfmdfivesum file{#3}}}{#1\let#2=\@undefined}% } \newcommand{\mpi@startfile}{% @@ -277,10 +279,13 @@ \PackageError{mpostinl}{no filename provided to write to}{}% \fi% \ifmpi@checksum\ifmpi@inclmod\else% - \mpi@getchecksum{\mpi@checksum@before}{\mpostfilename.mp}% + \mpi@getchecksum{\global}{\mpi@checksum@before}{\mpostfilename.mp}% \fi\fi% + \ifmpi@checksum\global\mpi@filemodfalse\else\global\mpi@filemodtrue\fi% + \ifmpi@inclmod\global\mpi@filemodtrue\fi% \global\mpi@infiletrue% \global\mpi@showinfilefalse% + \gdef\mpi@filelist{}% \ifmpi@write\immediate\openout\mpi@out\mpostfilename.mp\fi% \mpi@clearbuf% \mpi@beginfile% @@ -336,6 +341,30 @@ \fi\fi% } +\newcommand{\mpi@cleanfile}[1]{% + \immediate\openout\mpi@outnow#1% + \immediate\write\mpi@outnow{% + \@percentchar!PS-Adobe-3.0 EPSF-3.0^^J% + \@percentchar\@percentchar Title: missing figure file^^J% + \@percentchar\@percentchar Creator: mpostinl.sty^^J% + \@percentchar\@percentchar BoundingBox: -36 -22 36 22^^J% + \@percentchar\@percentchar EndComments^^J% + \@percentchar\@percentchar Page: 1 1^^J% + 0 setgray 0 1.5 dtransform truncate idtransform setlinewidth pop^^J% + [] 0 setdash 1 setlinecap 1 setlinejoin 10 setmiterlimit^^J% + newpath -35 21 moveto 35 -21 lineto stroke^^J% + newpath -35 -21 moveto 35 21 lineto stroke^^J% + \@percentchar\@percentchar EOF}% + \immediate\closeout\mpi@outnow% +} + +\newcommand{\mpi@cleanfiles}[1]{% + \begingroup\def\mpi@tmp{#1}% + \ifx\mpi@tmp\mpi@empty\else\def\mpi@tmp{\mpi@cleanfiles}% + \mpi@cleanfile{#1}\fi% + \expandafter\endgroup\mpi@tmp% +} + \newcommand{\mpi@closefile}{% \ifmpi@infile% \mpi@clearbuf% @@ -346,16 +375,15 @@ \mpi@endfile% \mpi@writebuf% \ifmpi@write\immediate\closeout\mpi@out\fi% - \mpi@filemodtrue% - \ifmpi@checksum\ifmpi@inclmod\else% - \mpi@getchecksum{\mpi@checksum@after}{\mpostfilename.mp}% - \ifx\mpi@checksum@before\mpi@checksum@after% - \mpi@filemodfalse% - \else% - \ifmpi@include\mpi@inclmodtrue\fi% - \fi% + \ifmpi@filemod\else% + \mpi@getchecksum{}{\mpi@checksum@after}{\mpostfilename.mp}% + \ifx\mpi@checksum@before\mpi@checksum@after\else\mpi@filemodtrue\fi% + \fi% + \ifmpi@include\ifmpi@filemod\global\mpi@inclmodtrue\fi\fi% + \ifmpi@filemod\ifmpi@inbody% + \ifmpi@clean\expandafter\mpi@cleanfiles\mpi@filelist{}\fi% + \mpi@compile{\mpostfilename.mp}% \fi\fi% - \ifmpi@filemod\ifmpi@inbody\mpi@compile{\mpostfilename.mp}\fi\fi% \ifmpi@filemod\ifmpi@showinfile\global\mpi@warnmodtrue\fi\fi% \global\mpi@infilefalse% \global\let\mpostfilename\mpi@empty% @@ -379,6 +407,7 @@ \mpi@endfile% \immediate\write\mpi@outnow{\the\mpi@buf}% \immediate\closeout\mpi@outnow% + \ifmpi@clean\mpi@cleanfile{\mpi@figfile}\fi% \mpi@compile{\mpi@nowname.mp}% \fi\fi\fi% } @@ -413,7 +442,7 @@ \mpi@addbuf{verbatimtex}% \fi% \mpi@verbatim% -}% +} {% \mpi@endverbatim% \ifmpi@deftex% @@ -468,14 +497,29 @@ \mpi@putlineno% \mpi@beginfig{\mpi@figfile}% \mpi@verbatim% -}% +} {% \mpi@endverbatim% \mpi@endfig% \mpi@writebuf% + \xdef\mpi@filelist{\mpi@filelist{\mpi@figfile}}% \ifmpi@now% \mpi@processnow% \fi% + \ifmpi@filemod\else% + \mpi@getchecksum{}{\mpi@tmpa}{\mpi@figfile}% + \ifdefined\mpi@tmpa% + \edef\mpi@tmpa{\scantokens\expandafter{\mpi@tmpa\noexpand}}% + \def\mpi@tmpb{965DFFE32ABB43CC14C58E254B4D660E}% + \ifx\mpi@tmpa\mpi@tmpb\global\mpi@filemodtrue\fi% + \def\mpi@tmpb{D78A5F2EE4B244260ECD6A0E89ADC9CE}% + \ifx\mpi@tmpa\mpi@tmpb\global\mpi@filemodtrue\fi% + \def\mpi@tmpb{D41D8CD98F00B204E9800998ECF8427E}% + \ifx\mpi@tmpa\mpi@tmpb\global\mpi@filemodtrue\fi% + \else% + \global\mpi@filemodtrue% + \fi + \fi% \ifmpi@figshow% \expandafter\mpi@graphics\mpi@figopt{\mpi@figfile}% \ifmpi@now\else\global\mpi@showinfiletrue\fi% -- cgit v1.2.3