diff options
author | Karl Berry <karl@freefriends.org> | 2023-01-29 21:19:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-01-29 21:19:02 +0000 |
commit | efa996f0ccdf4a4c8d58c684c3db409576010abd (patch) | |
tree | aeb04caf4628a2944921f389393328093c205553 /Master/texmf-dist/tex | |
parent | 9a0f81f763800ac105de14aae1d06470106c1493 (diff) |
hvextern (29jan23)
git-svn-id: svn://tug.org/texlive/trunk@65670 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rwxr-xr-x | Master/texmf-dist/tex/latex/hvextern/hvextern-checkfile.lua | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/hvextern/hvextern.sty | 354 |
2 files changed, 346 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern-checkfile.lua b/Master/texmf-dist/tex/latex/hvextern/hvextern-checkfile.lua index 627f86d6bb8..ea163c6a72c 100755 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern-checkfile.lua +++ b/Master/texmf-dist/tex/latex/hvextern/hvextern-checkfile.lua @@ -6,7 +6,7 @@ -- AUTHOR: Herbert Voß -- LICENSE: LPPL1.3 -- --- $Id: hvextern.lua 578 2022-06-20 16:41:45Z herbert $ +-- $Id: hvextern-checkfile.lua 585 2022-07-21 13:28:06Z herbert $ ----------------------------------------------------------------------- kpse.set_program_name("luatex") diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty index bf769253083..9f90b708a2b 100644 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty +++ b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty @@ -1,7 +1,7 @@ -%% $Id: hvextern.sty 579 2022-06-20 19:23:29Z herbert $ +%% $Id: hvextern.sty 678 2023-01-29 09:59:12Z herbert $ %% This is file `hvextern.sty', %% -%% Copyright (C) 2016-22 +%% Copyright (C) 2016-23 %% Herbert Voss %% %% It may be distributed and/or modified under the @@ -12,8 +12,8 @@ %% and version 1.3c or later is part of all distributions of LaTeX %% version 2005/12/01 or later. -\def\hvexternFileversion{0.32} -\ProvidesFile{hvextern}[2022/06/23 v\hvexternFileversion: package for running external documents (HV)] +\def\hvexternFileversion{0.33} +\ProvidesFile{hvextern}[2023/01/29 v\hvexternFileversion: package for running external documents (HV)] \newif\ifhv@extern@checkCode \hv@extern@checkCodefalse @@ -29,6 +29,7 @@ \def\hv@ex@typeout#1{\ifhv@extern@verbose\typeout{>>(hvextern) #1}\fi} + \ifwindows \def\hv@move{move }% \def\hv@rm{del }% @@ -287,18 +288,18 @@ \hv@ex@typeout{Running PreambleListing with #1, #2}% \ifhv@extern@tcbox \begin{tcolorbox}[before skip=0pt,after skip=0pt,breakable,enhanced jigsaw%,top=-2pt - ]\expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}\end{tcolorbox}% + ]\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}% \else - \expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}% + \expandafter\lstinputlisting\expandafter[#1]{#2}% \fi} \newcommand\BodyListing[2][]{% \hv@ex@typeout{Running BodyListing with #1, #2}% \ifhv@extern@tcbox \begin{tcolorbox}[before skip=0pt,after skip=0pt,breakable,enhanced jigsaw,%top=-2pt - ]\expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}\end{tcolorbox}% + ]\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}% \else - \expandafter\lstinputlisting\expandafter[#1,aboveskip=0pt,belowskip=0pt]{#2}% + \expandafter\lstinputlisting\expandafter[#1]{#2}% \fi} \newcounter{hv@example@counter} @@ -516,6 +517,7 @@ \fi% end force \hfuzz=\maxdimen \ifhv@extern@code%-------------- Code Part + \vspace{\hv@extern@aboveskip}% \hv@ex@typeout{Starting Code part with preamble ...}% \begingroup \if@twocolumn @@ -658,7 +660,7 @@ \vspace{\hv@extern@belowskip}% } -\newcommand\runExtCmd[3][]{% +\newcommand\runExtCmd[3][]{% #1:options; #2:comamnd; #3:filename \begingroup \setkeys{hv}{cleanup={},code=false,includegraphic=false,#1}% \xdef\hvExternDateiname{#3-\arabic{hv@example@counter}}% @@ -732,6 +734,340 @@ \endgroup } +\def\WriteVerb{\FV@Environment{}{WriteVerb}} +\def\FVB@WriteVerb#1{% + \@bsphack + \begingroup + \FV@UseKeyValues + \FV@DefineWhiteSpace + \def\FV@Space{\space}% + \FV@DefineTabOut + \def\FV@ProcessLine{\immediate\write\FV@OutFile}% + \immediate\openout\FV@OutFile #1\relax + \let\FV@FontScanPrep\relax + \let\@noligs\relax + \FV@Scan} +\def\FVE@WriteVerb{\immediate\closeout\FV@OutFile\endgroup\@esphack} +\DefineVerbatimEnvironment{WriteVerb}{WriteVerb}{} + +\begingroup +\catcode`\^^M=\active + \gdef\FV@BeginScanning#1^^M{% + \def\@tempa{#1}\ifx\@tempa\@empty\else\FV@BadBeginError\fi% <------ + \FV@GetLine}% +\gdef\FancyVerbGetLine#1^^M{% + \@nil + \FV@CheckEnd{#1}% + \ifx\@tempa\FV@EnvironName% % True if end is found + \ifx\@tempb\FV@@@CheckEnd\else\FV@BadEndError\fi% + \let\next\FV@EndScanning% + \else% + \def\FV@Line{#1}% + \def\next{\FV@PreProcessLine\FV@GetLine}% + \fi% + \next}% +\endgroup + +{\catcode`\ =12 \gdef\FancyVerbSpace{\ttfamily }} + +\newcommand\BeginPSTcode{% + \nobreak + \VerbatimEnvironment + \catcode`\<=12 + \begin{VerbatimOut}{\EX@dir\EX@prefix\theEX@ct.\EX@suffix}} +% +\newcommand\EndPSTcode{% +\end{VerbatimOut} + \global\let\Preamble@Commands\@empty + \global\let\Hidden@Preamble@Commands\@empty + \global\let\Require@Packages\@empty +} +% +\renewcommand\FVE@VerbatimOut{% + \Write@Postamble + \immediate\closeout\FV@OutFile\endgroup\@esphack} + +\newcommand\Write@Ex[1]{% + \begingroup + \let\protect\@unexpandable@protect + \edef\reserved@a{\immediate\write\FV@OutFile{#1}}% + \reserved@a + \endgroup} + +\newcommand\Write@ExOne[1]{{% + \@temptokena\expandafter{#1}% + \immediate\write\FV@OutFile{\the\@temptokena}}} + +\renewcommand\FVB@VerbatimOut[1]{% + \@bsphack + \begingroup + \FV@UseKeyValues% + \FV@DefineWhiteSpace% + \def\FV@Space{\space}% + \FV@DefineTabOut% + \def\FV@ProcessLine##1{\toks@{##1}\immediate\write\FV@OutFile{\the\toks@}}% + \immediate\openout\FV@OutFile #1\relax% + \Write@Preamble + \let\FV@FontScanPrep\relax + \let\@noligs\relax% + \FV@Scan} +% + +\newcommand\Write@Preamble@PST{% + \Write@Ex{\string\documentclass[pstricks]{standalone}}% + \Write@Ex{\string\pagestyle{empty}}% + \ifx\Preamble@Commands\@empty\else + \Write@Ex{\Preamble@Commands}% + \fi + \Write@Ex{\string\begin{document}}% +} +% +%\hv@extern@ExampleType{ltx} +% {\Write@Preamble@LaTeX} +% {\Write@Ex{\string\end{document}}} +% {\string\begin{document}} +% {\string\end{document}} +% {\perCent StartShownPreambleCommands} +% {\perCent StopShownPreambleCommands} + +\newenvironment{createPNGfromPSTricks}[3][]% #1:options #2: pstricks packages #3: filename + {% + \xdef\hvExternDateiname{#2-\arabic{hv@example@counter}}% + \gdef\hv@extern@savePara{#1}% + \setkeys{hv}{#1}% \begin + \hv@ex@typeout{External filename: \hvExternDateiname}% + \expandafter\IfFileExists\expandafter{\hv@extern@ExamplesDir\hvExternDateiname.pdf}{}{% + \expandafter\IfFileExists\expandafter{\hv@extern@ExamplesDir\hvExternDateiname.png}{}{% + \expandafter\IfFileExists\expandafter{\hv@extern@ExamplesDir\hvExternDateiname.txt}{}{% + \global\hv@extern@forcetrue}}}% set force, if no pdf or png exists + \begingroup + \hv@ex@typeout{writing file \hvExternDateiname\hv@extern@ext ...}% + \filecontents[force,noheader]{\hvExternDateiname\hv@extern@ext}% + } + {\endfilecontents% \end% + \hv@ex@typeout{... done}% + \global\stepcounter{hv@example@counter}% + \endgroup + \expandafter\hvExternSetKeys\expandafter{\hv@extern@savePara}% + \xdef\hv@extern@fullPath{\hv@extern@ExamplesDir\hvExternDateiname}% + \ifhv@extern@checkCode + \ifluatex + \directlua{if GetFileContents("\hvExternDateiname\hv@extern@ext", + "\hv@extern@ExamplesDir\hvExternDateiname\hv@extern@ext") then + tex.print("\\csname hv@ex@typeout\\endcsname{current file is NOT newer: no run }\\global\\csname hv@extern@forcefalse\\endcsname") + else + tex.print("\\csname hv@ex@typeout\\endcsname{current file is newer: force run }\\global\\csname hv@extern@forcetrue\\endcsname") + end}% + \else + \hv@ex@typeout{Check, if new file has a different code}% + \ShellEscape{hvextern-checkfile "\hvExternDateiname\hv@extern@ext" + "\hv@extern@ExamplesDir\hvExternDateiname\hv@extern@ext"}% + \InputIfFileExists{\hvExternDateiname\hv@extern@ext.diff}{}{}% + \ifx\hvCheckNewFile\empty + \hv@ex@typeout{current file is NOT newer: no run }% + \global\hv@extern@forcefalse + \else + \hv@ex@typeout{current file is newer: force run }% + \global\hv@extern@forcetrue + \fi + \ifhv@extern@verbose\else\hv@rm{\hvExternDateiname\hv@extern@ext.diff}\fi + \fi + \fi + \ifhv@extern@force + \ifx\hv@extern@runsequence\@empty + \hv@ex@typeout{force=true: running \hv@extern@progpath\hv@extern@compiler~ \hvExternDateiname\hv@extern@ext ...}% + \setcounter{@@@runs}{\value{hv@extern@runs}}% + \loop\ifnum\the@@@runs > 0\relax + \ifcase\hv@extern@compilerNo \relax % we have metapost + \hv@ex@typeout{running mpost \hvExternDateiname\hv@extern@ext}% + \hv@extern@runMP{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% + \or %1 + \hv@ex@typeout{running tex \hvExternDateiname\hv@extern@ext}% + \hv@extern@runTEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% + \or %2 + \hv@ex@typeout{running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}% + \hv@extern@runLATEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}% + \else + \ifhv@extern@redirect + \hv@ex@typeout{running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext > \hvExternDateiname.txt}% + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext\space > \hvExternDateiname.txt}% + \else + \hv@ex@typeout{running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}% + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext}% + \fi + \fi + \addtocounter{@@@runs}{-1}% + \repeat + \hv@ex@typeout{... done}% + \ifhv@extern@biber + \ShellEscape{biber \hvExternDateiname}% NAch biber nochmal latex + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname}% + \fi + \ifhv@extern@xindex + \ShellEscape{xindex \hv@extern@xindexOptions\space \hvExternDateiname.idx}% NAch xindex nochmal latex + \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname}% + \fi + \else % runsequence + \expandafter\run@hv@extern@sequenceList\expandafter{\hv@extern@runsequence}% + \fi + \ifhv@extern@crop + \ShellEscape{pdfcrop --margins \hv@extern@cropmargin \hvExternDateiname}% + \ShellEscape{\hv@move \hvExternDateiname-crop.pdf \hvExternDateiname.pdf}% + \fi + \ifhv@extern@eps + \ShellEscape{pdftops -eps -f 1 -l 1 \hvExternDateiname.pdf}% + \fi + \else + \hv@ex@typeout{force=false: NOT running \hvExternDateiname\hv@extern@ext ...}% + \fi% end force + \hfuzz=\maxdimen + \ifhv@extern@code%-------------- Code Part + \hv@ex@typeout{Starting Code part with preamble ...}% + \begingroup + \if@twocolumn + \ifhv@extern@outerFN + \hv@TextWidth=\textwidth + \else + \hv@TextWidth=\columnwidth + \fi + \else + \hv@TextWidth=\textwidth + \fi + \ifdim\hv@extern@mpwidth>\z@ + \noindent + \tcbset{breakable=false}% + \minipage[\hv@extern@mpvalign]{\hv@extern@mpwidth} + \vspace{0pt}% + \else + \vspace{\hv@extern@aboveskip}\noindent + \fi + \ifhv@extern@usefancyvrb + \@nameuse{\hv@extern@docType @initPreambleFancy}% + \edef\@@@temp{\@nameuse{\hv@extern@docType @initPreamble}}% + % we need lstinputlisting, because \VerbatimInput doesn't work in a box + \savebox\hv@extern@box{\expandafter\lstinputlisting\expandafter[\@@@temp]{\hvExternDateiname\hv@extern@ext}}% + \ifdim\wd\hv@extern@box > \z@\relax + \expandafter\fvset\expandafter{\hv@extern@lstOptions}% + \tcbset{colback=\hv@extern@BGpreamble,colframe=\hv@extern@BOpreamble}% + \PreambleVerbatim{\hvExternDateiname\hv@extern@ext}% + \vspace{\hv@extern@belowpreambleskip}% + \fi + \else + \edef\@@@temp{\@nameuse{\hv@extern@docType @initPreamble}}% + \savebox\hv@extern@box{\expandafter\lstinputlisting\expandafter[\@@@temp]{\hvExternDateiname\hv@extern@ext}}% + \ifdim\wd\hv@extern@box>\z@\relax + \expandafter\lstset\expandafter{\hv@extern@lstOptions}% + \tcbset{colback=\hv@extern@BGpreamble,colframe=\hv@extern@BOpreamble}% + \PreambleListing[\@@@temp]{\hvExternDateiname\hv@extern@ext}% + \vspace{\hv@extern@belowpreambleskip}% + \fi + \fi + \ifhv@extern@showFilename + \hv@ex@typeout{Set filename in the margin!}% + \noindent + \hfuzz=\maxdimen + \hv@marginpar{\hvExternDateiname\hv@extern@ext}% + \fi +% + \hv@ex@typeout{Starting Code body ...}%} + \ifhv@extern@usefancyvrb + \@nameuse{\hv@extern@docType @initTextFancy}% + \expandafter\fvset\expandafter{\hv@extern@lstOptions}% + \tcbset{colback=\hv@extern@BGbody,colframe=\hv@extern@BObody}% + \expandafter\BodyVerbatim\expandafter[\hv@extern@lstOptions]{\hvExternDateiname\hv@extern@ext}% + \else + \expandafter\lstset\expandafter{\hv@extern@lstOptions}% + \edef\@@@temp{\@nameuse{\hv@extern@docType @initText}}% + \tcbset{colback=\hv@extern@BGbody,colframe=\hv@extern@BObody}% + \BodyListing[\@@@temp]{\hvExternDateiname\hv@extern@ext}% + \fi + \ifdim\hv@extern@mpwidth > \z@\relax \endminipage\fi + \endgroup + \fi % end code part + \ifhv@extern@code\else % only if no code + \ifhv@extern@showFilename + \hv@ex@typeout{Set filename in the margin!}% + \noindent + \hv@marginpar{\hvExternDateiname\hv@extern@ext}% + \fi + \fi + \ifhv@extern@moveToExampleDir +% \ShellEscape{mkdir\space\hv@extern@ExamplesDir/}% + \hv@ex@typeout{Move file into example dir}% + \hv@ex@typeout{\hvExternDateiname ----> \hv@extern@ExamplesDir}% + \ShellEscape{\hv@move \hvExternDateiname.*\space \hv@extern@ExamplesDir}% + \fi + \ifhv@extern@showoutput + \ifhv@extern@includegraphic + \ifhv@extern@inline + \expandafter\includegraphics\expandafter[\hv@extern@grfOptions]{\hv@extern@fullPath}% + \else + \ifhv@extern@float + \hv@ex@typeout{Floating environment}% + \expandafter\figure\expandafter[\hv@extern@floatsetting] + \else + \hv@ex@typeout{No floating environment}% + \vspace{\hv@extern@belowbodyskip} + \ifdim\hv@extern@mpwidth>\z@ + \hfill\minipage[\hv@extern@mpvalign]{\dimexpr\linewidth-\hv@extern@mpwidth-1em\relax}\vspace{0pt}% + \else + \vspace{\hv@extern@belowbodyskip}\noindent + \begingroup + \fi + \fi + \hv@extern@align + \hv@ex@typeout{Input image \hv@extern@fullPath}% + \ifhv@extern@frame + \begingroup + \fboxsep=\hv@extern@framesep + \expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{% + \fbox{\expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]% + {\hv@extern@fullPath}}\hspace{\hv@extern@pagesep}}% + \hspace*{-\hv@extern@pagesep}% + \endgroup + \else + \expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{% + \expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]% + {\hv@extern@fullPath}\hspace{\hv@extern@pagesep}}% + \hspace*{-\hv@extern@pagesep}% + \fi + \par% for \hv@extern@align + \ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi + \ifx\hv@extern@label\@empty\else\label{\hv@extern@label}\fi + \ifhv@extern@float + \endfigure + \else + \ifdim\hv@extern@mpwidth>\z@ \endminipage\else\endgroup\fi + \fi + \fi + \else% no graphic, only text + \ifdim\hv@extern@mpwidth>\z@ + \hfill\minipage[t]{\dimexpr\linewidth-\hv@extern@mpwidth-\hv@extern@mpsep\relax}\vspace{0pt} + \ifhv@extern@usefancyvrb + \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% + \else + \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% + \fi + \endminipage + \else + \vspace{\hv@extern@belowbodyskip}% + \noindent + \ifhv@extern@usefancyvrb + \expandafter\VerbatimInput\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% + \else + \expandafter\lstinputlisting\expandafter[\hv@extern@textOptions]{\hv@extern@fullPath.txt}% + \fi + \fi + \fi + \fi% end of \ifshowoutput + \ifhv@extern@force\expandafter\run@hv@extern@cleanup\expandafter{\hv@extern@cleanup}\fi% cleanup + \vspace{\hv@extern@belowskip}% +} + + + + + \stepcounter{hv@example@counter}% % %% |