From e1088ee8b152b286a7f2898ebacbc2d97c12c70e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 20 Jun 2022 21:07:45 +0000 Subject: hvextern (20jun22) git-svn-id: svn://tug.org/texlive/trunk@63664 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/hvextern/Changes | 2 + Master/texmf-dist/doc/latex/hvextern/hvextern.pdf | Bin 1425099 -> 1425940 bytes Master/texmf-dist/doc/latex/hvextern/hvextern.tex | 99 ++++++++++++---------- Master/texmf-dist/tex/latex/hvextern/hvextern.lua | 28 ++++++ Master/texmf-dist/tex/latex/hvextern/hvextern.sty | 48 +++++++++-- 5 files changed, 125 insertions(+), 52 deletions(-) create mode 100644 Master/texmf-dist/tex/latex/hvextern/hvextern.lua (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/hvextern/Changes b/Master/texmf-dist/doc/latex/hvextern/Changes index e9b70b00279..73630cf1873 100644 --- a/Master/texmf-dist/doc/latex/hvextern/Changes +++ b/Master/texmf-dist/doc/latex/hvextern/Changes @@ -1,5 +1,7 @@ hvextern.sty ---------------- +v 0.31 2022-06-20 - added package option checkCode to run the external + file only if the code changes. v 0.30 2022-06-09 - added \hfuzz=\maxdimen for filename to prevent overfull box messages v 0.29 2022-06-06 - use skin "enhanced jigsaw" for tcolorbox diff --git a/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf b/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf index 0f2754a1786..6e11028f20f 100644 Binary files a/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf and b/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf differ diff --git a/Master/texmf-dist/doc/latex/hvextern/hvextern.tex b/Master/texmf-dist/doc/latex/hvextern/hvextern.tex index 724f779a736..d3f81f74472 100644 --- a/Master/texmf-dist/doc/latex/hvextern/hvextern.tex +++ b/Master/texmf-dist/doc/latex/hvextern/hvextern.tex @@ -1,4 +1,4 @@ -%% $Id: hvextern.tex 574 2022-06-09 19:34:31Z herbert $ +%% $Id: hvextern.tex 577 2022-06-20 16:35:21Z herbert $ \RequirePackage{pdfmanagement-testphase} \DeclareDocumentMetadata{} \documentclass[ngerman,a4paper,twoside]{article} @@ -10,7 +10,7 @@ \usepackage{fancyhdr} \pagestyle{fancy} \usepackage{hvlogos} -\usepackage{hvextern} +\usepackage[checkCode]{hvextern} \usepackage{hvindex} \usepackage{hvdoctools} \usepackage{listings} @@ -34,14 +34,24 @@ from within a main\newline \LaTeX\ document~--v. \hvexternFileversion} %\newpage \setkeys{hv}{moveToExampleDir,ExampleDir=Exa,showFilename,verbose} -\section{Syntax} + + +\clearpage + +\section{Loading the package} \begin{verbatim} -\usepackage{hvextern} +\usepackage[Option]{hvextern} \end{verbatim} -\addtocontents{toc}{\protect\enlargethispage{2ex}} +There exists only one option \Loption{checkCode} which is only valid +for the use of \LuaLaTeX. In this case an already existing external file will only be compiled, if the +code changed. This dosn't depends on the setting of the option \Lkeyword{force}. +The package option will speed up the compilation time. +\section{Syntax} + +\addtocontents{toc}{\protect\enlargethispage{2ex}} \begin{sloppypar} This package allows to write external \MP, \TeX, \ConTeXt, \LaTeX, \LuaTeX, \LuaLaTeX, \XeTeX, \XeLaTeX, @@ -96,7 +106,7 @@ outside of the main document and then to insert the output we can do this from within this \LuaLaTeX\ document itself. The external document is compiled with \XeLaTeX\ and the output is insert as pdf image: \begin{externalDocument}[% - compiler=xelatex, inline, force, runs=2, grfOptions={height=8pt},% + compiler=xelatex, inline, force=false, runs=2, grfOptions={height=8pt},% crop, cropmargin=0, cleanup, docType=latex]{voss} \documentclass{ctexart} \pagestyle{empty} @@ -112,7 +122,7 @@ shown by the environment \Lenv{externalDocument}. \begin{minipage}{.59\linewidth} \begin{lstlisting} \begin{externalDocument}[ - compiler=pdflatex,force,cleanup]{voss} + compiler=pdflatex,force=false,cleanup]{voss} \documentclass{standalone} %StartVisiblePreamble \usepackage{fontenc} @@ -136,7 +146,7 @@ shown by the environment \Lenv{externalDocument}. \end{minipage} \begin{minipage}{.39\linewidth} \begin{externalDocument}[ - compiler=pdflatex,force=true,cleanup={log,aux},showFilename=false]{voss} + compiler=pdflatex,force=false,cleanup={log,aux},showFilename=false]{voss} \documentclass{standalone} %StartVisiblePreamble \usepackage{fontenc} @@ -192,7 +202,7 @@ catagory, which is done internally by the package. The complete definition of th compiler=python3, code, ext=py, - force=true, + force=false, docType=py, usefancyvrb, grfOptions={width=\linewidth}]{python} @@ -242,7 +252,7 @@ line in the above code shows how it can be done with Python. \begin{externalDocument}[ compiler=python3, progpath=/usr/local/bin/, - force=true, + force=false, runs=1, code, ext=py, @@ -292,6 +302,8 @@ set in twocolumn mode but inside a starred floating environment over both column, then use the keyword \Lkeyword{outerFN}. Then \Lpack{hvextern} doesn't test for twocolumn mode. +\enlargethispage{\normalbaselineskip} + A vertical shift of the filename is possible by setting a length to the keyword \Lkeyword{shiftFN}, e.g. \texttt{shiftFN=5ex}. @@ -300,7 +312,7 @@ e.g. \texttt{shiftFN=5ex}. \begin{externalDocument}[grfOptions={width=0.95\linewidth}, compiler=xelatex,code,mpwidth=0.6\linewidth, - crop,cleanup,force=true,usefancyvrb=false,ext=tex,showFilename=false]{voss} + crop,cleanup,force=false,usefancyvrb=false,ext=tex,showFilename=false]{voss} \documentclass{article} %StartVisiblePreamble \usepackage{tikz} @@ -412,7 +424,7 @@ runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex} runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}, , verbose, - force=true, + force=false, cleanup={log,aux,toc,bbl,blg}, code,docType=latex, lstOptions={columns=fixed}]{voss} @@ -451,7 +463,7 @@ the environment \Lenv{externalDocument} is: \begin{externalDocument}[ verbose, compiler=java,ext=java,code, - force=true,docType=java,includegraphic, + force=false,docType=java,includegraphic, usefancyvrb,grfOptions={width=0.9\linewidth}]{java} import java.awt.Color; import java.awt.Graphics; @@ -582,7 +594,7 @@ to \Lcs{VerbatimInput}. The following example uses mpwidth=0.6\linewidth, crop, cleanup, - force=true, + force=false, docType=latex]{voss} \RequirePackage{pdfmanagement-testphase} \DeclareDocumentMetadata{} @@ -630,7 +642,7 @@ The color of the frame is set to the same values, hence not seen. The following mpwidth=0.6\linewidth, crop, cleanup, - force=true, + force=false, usefancyvrb, docType=latex]{voss} \RequirePackage{pdfmanagement-testphase} @@ -717,7 +729,7 @@ The following example uses: % mpwidth=0.6\linewidth, % crop, cleanup, - force=true, + force=false, frame, % usefancyvrb, % float, @@ -770,7 +782,7 @@ which is the default. Using a caption and a label are optional. % mpwidth=0.6\linewidth, crop, cleanup, - force=true, + force=false, usefancyvrb, float, floatsetting=!ht, @@ -833,7 +845,7 @@ The follwoing example was created with % mpwidth=0.6\linewidth, crop, cropmargin=5, cleanup, - force=true, + force=false, frame, % usefancyvrb, % float, @@ -894,7 +906,7 @@ or \Lkeyval{b}. showFilename=false, crop, cleanup, - force=true, + force=false, docType=latex]{voss} \documentclass{article} \pagestyle{empty} @@ -918,7 +930,7 @@ or \Lkeyval{b}. code, crop, cleanup, - force=true, + force=false, docType=latex]{voss} \documentclass{article} \pagestyle{empty} @@ -943,7 +955,7 @@ or \Lkeyval{b}. showFilename=false, crop, cleanup, - force=true, + force=false, docType=latex]{voss} \documentclass{article} \pagestyle{empty} @@ -968,7 +980,7 @@ or \Lkeyval{b}. crop, showFilename=false, cleanup, - force=true, + force=false, mpwidth=0.5\linewidth, docType=latex]{voss} \documentclass{article} @@ -993,7 +1005,7 @@ or \Lkeyval{b}. showFilename=false, crop, cleanup, - force=true, + force=false, mpwidth=0.5\linewidth, docType=latex]{voss} \documentclass{article} @@ -1019,7 +1031,7 @@ or \Lkeyval{b}. showFilename=false, crop, cleanup, - force=true, + force=false, mpwidth=0.5\linewidth, docType=latex]{voss} \documentclass{article} @@ -1049,7 +1061,7 @@ next Chinese characters \begin{externalDocument}[ compiler=xelatex, inline, runs=2, grfOptions={height=8pt}, crop, cropmargin=0, - cleanup, force=true, docType=latex]{voss}% + cleanup, force=false, docType=latex]{voss}% \documentclass{ctexart} \pagestyle{empty} \begin{document} @@ -1065,7 +1077,7 @@ With \Lkeyset{inline} the optional argument \Lkeyword{code} is automatically set to false. The next Chinese characters \begin{externalDocument}[ compiler=xelatex, inline, runs=2, grfOptions={height=8pt}, - crop, cropmargin=0, cleanup, force=true, docType=latex]{voss} + crop, cropmargin=0, cleanup, force=false, docType=latex]{voss} \documentclass{ctexart} \pagestyle{empty} \begin{document} @@ -1104,7 +1116,7 @@ sorted digits of the number $A$: $495=954-459$. \begin{externalDocument}[ - compiler=perl, force=true, docType=pl, ext=pl, includegraphic=false, + compiler=perl, force=false, docType=pl, ext=pl, includegraphic=false, code, mpwidth=0.6\linewidth]{voss} #!/usr/bin/perl # @@ -1159,7 +1171,7 @@ outFile = io.open(shortFN..".txt","w+") -- open external file \begin{externalDocument}[ - compiler=lua, force=true, docType=lua, ext=lua, includegraphic=false, + compiler=lua, force=false, docType=lua, ext=lua, includegraphic=false, code, usefancyvrb=false,textOptions={basicstyle=\ttfamily\footnotesize}, shiftFN=6ex]{voss} #!/usr/bin/env lua @@ -1234,7 +1246,7 @@ The following examples uses pages=2, crop, cleanup, - force=true, + force=false, xindex, xindexOptions={-l DE --config AU}, mpwidth=0.6\linewidth, @@ -1290,7 +1302,7 @@ runsequence={lualatex,biber,{xindex -l de -c AU},lualatex,lualatex} frame, runsequence={lualatex,biber,xindex -l de -c AU,lualatex,lualatex}, verbose, - force=true, + force=false, cleanup={log,aux,toc,bbl,blg}, code,docType=latex, lstOptions={columns=fixed}]{voss} @@ -1330,7 +1342,7 @@ The default is using \Lcs{lstinputlisting} for the printed code sequences. pages={1,3}, frame,compiler=pdflatex, % crop, - force=true,runs=2,code,docType=latex, + force=false,runs=2,code,docType=latex, frame, lstOptions={columns=fixed}]{voss} %StartVisiblePreamble @@ -1390,7 +1402,7 @@ it makes no difference using the optional argument \Lkeyword{usefancyvrb} or not frame,compiler=pdflatex, showFilename, % crop, - force=true,runs=2,code,docType=latex, + force=false,runs=2,code,docType=latex, frame,framesep=0pt,usefancyvrb]{voss} %StartVisiblePreamble \documentclass[chapterprefix=on,parskip=half-,DIV=12,fontsize=12pt]{scrbook} @@ -1474,7 +1486,7 @@ other examples, you can set \Lkeyword{showoutput} to false. showoutput=false, frame,compiler=pdflatex, crop, - force,runs=2,code,docType=latex, + force=false,runs=2,code,docType=latex, frame,usefancyvrb]{voss} %StartVisiblePreamble \documentclass[chapterprefix=on,parskip=half-,DIV=12,fontsize=12pt]{scrbook} @@ -1550,7 +1562,7 @@ Whith this definition and the setting \Lkeyset{docType=ltx} the last example loo frame, compiler=pdflatex, showFilename, - force=true, + force=false, runs=2,code,docType=ltx, usefancyvrb]{voss} \documentclass[chapterprefix=on,parskip=half-,DIV=12,fontsize=12pt]{scrreprt} @@ -1614,7 +1626,7 @@ It is already internally defined. compiler=mpost, showFilename, % crop, - force=true, + force=false, cleanup, code, docType=mp, @@ -1650,7 +1662,7 @@ It is already internally defined. compiler=tex, showFilename, % crop, - force=true, + force=false, code, docType=tex, ext=tex,]{voss} @@ -1716,7 +1728,7 @@ not needed. The \texttt{pdf} is directly created. compiler=lualatex, showFilename, crop, - force=true, + force=false, code, docType=latex, ext=tex,]{voss} @@ -1758,7 +1770,7 @@ not needed. The \texttt{pdf} is directly created. compiler=context, showFilename, runs=2, - force=true, + force=false, code, docType=context, ext=tex,]{voss} @@ -1769,9 +1781,9 @@ not needed. The \texttt{pdf} is directly created. \setuphead [myhead] [numberstyle=bold, - textstyle=bold, - before=\hairline\blank, - after=\nowhitespace\hairline] + textstyle =bold, + before =\hairline\blank, + after =\nowhitespace\hairline] %StopVisiblePreamble \starttext \startstandardmakeup @@ -1797,7 +1809,7 @@ not needed. The \texttt{pdf} is directly created. \chapter[cuyler]{The Cuyler family} ... much later Tydeman Cuyler ... \input knuth -\myhead[headlines]{And the end} +\myhead[headlines]{And the end of all} foo \stoptext \end{externalDocument} @@ -1829,7 +1841,8 @@ to get the directory listed: % to get the filename on the right or left of the whole page. %\item[\Lkeyword{shiftFN}] A length to move the printed filename up or down. \item[\Lkeyset{force=false}] can speed up the comiling time for the document. If a created image/output -already exists, there is no need to create it with the next run again and again. +already exists, there is no need to create it with the next run again and again. \emph This option is not valid +if the package option \Loption{checkCode} exists. \item[\Lkeyword{cleanup}] the auxiliary files of a \LaTeX-run are deleted, preset to \texttt{aux}, \texttt{log}. It must be a comma seperated list of the extensions of the main file, s.g. \texttt{cleanup=\{aux,log\}}. \item[\Lkeyword{copyToExampleDir}] name of a directory for the examples, must first be created by the user himself diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern.lua b/Master/texmf-dist/tex/latex/hvextern/hvextern.lua new file mode 100644 index 00000000000..8f23c6a9bdf --- /dev/null +++ b/Master/texmf-dist/tex/latex/hvextern/hvextern.lua @@ -0,0 +1,28 @@ +----------------------------------------------------------------------- +-- FILE: hvextern.lua +-- DESCRIPTION: check two files for identical code +-- REQUIREMENTS: +-- AUTHOR: Herbert Voß +-- LICENSE: LPPL1.3 +-- +-- $Id: hvextern.lua 578 2022-06-20 16:41:45Z herbert $ +----------------------------------------------------------------------- +kpse.set_program_name("luatex") + +function GetFileContents(f1,f2) + local NewContents, OldContents + local File = io.open(f1) + if File then + NewContents = File:read('*all') + File:close() + end + local File = io.open(f2) + if File then + OldContents = File:read('*all') + File:close() + end + return NewContents == OldContents +end + +--local f1 = arg[1] +--local f2 = arg[2] \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty index 1ad9c182092..a7340a2f12c 100644 --- a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty +++ b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty @@ -1,4 +1,4 @@ -%% $Id: hvextern.sty 574 2022-06-09 19:34:31Z herbert $ +%% $Id: hvextern.sty 577 2022-06-20 16:35:21Z herbert $ %% This is file `hvextern.sty', %% %% Copyright (C) 2016-22 @@ -12,21 +12,33 @@ %% and version 1.3c or later is part of all distributions of LaTeX %% version 2005/12/01 or later. -\def\hvexternFileversion{0.30} -\ProvidesFile{hvextern}[2022/06/09 v\hvexternFileversion: package for running external documents (HV)] +\def\hvexternFileversion{0.31} +\ProvidesFile{hvextern}[2022/06/20 v\hvexternFileversion: package for running external documents (HV)] + +\newif\ifhv@extern@checkCode +\hv@extern@checkCodefalse +\DeclareOption{checkCode}{\hv@extern@checkCodetrue} + +\ProcessOptions \RequirePackage{shellesc,xkeyval,graphicx} -\RequirePackage{fancyvrb,tikz,listings,ifplatform} -\RequirePackage{ifoddpage} +\RequirePackage{fancyvrb,tikz,listings,ifplatform,iftex} +\RequirePackage{ifoddpage,filemod} \RequirePackage{tcolorbox,xparse} \tcbuselibrary{skins,breakable} +\def\hv@ex@typeout#1{\ifhv@extern@verbose\typeout{>>(hvextern) #1}\fi} + \ifwindows \def\hv@move{move }% \def\hv@rm{del }% + \def\hv@mkdir{mkdir }% \else - \def\hv@move{mv } - \def\hv@rm{rm } + \def\hv@move{mv }% + \def\hv@move{mv }% + \def\hv@rm{rm }% + \def\hv@mkdir{mkdir -p }% + \def\hv@diff{diff } \fi \newcounter{hv@extern@runs} @@ -105,7 +117,6 @@ } \define@boolkey{hv}[hv@extern@]{eps}[true]{} \define@boolkey{hv}[hv@extern@]{verbose}[true]{} -\def\hv@ex@typeout#1{\ifhv@extern@verbose\typeout{>>(hvextern) #1}\fi} \define@choicekey*+{hv}{compiler}[\val\nr]{mpost,tex,latex,luatex,python3,perl,lua,java,% xetex,pdflatex,lualatex,xelatex,context,sh,texlua}[pdflatex]{% @@ -177,9 +188,20 @@ }% } - \ResetKeys +\ifluatex + \ifhv@extern@checkCode + \hv@ex@typeout{Loading hvextern.lua}% + \directlua{dofile("hvextern.lua")}% + \fi +\else + \ifhv@extern@checkCode + \hv@ex@typeout{You need lualatex for option checkCode. Will disable the option!}% + \hv@extern@checkCodefalse + \fi +\fi + {\catcode`\%=12 \catcode`\#=12 \gdef\perCent{%} @@ -422,6 +444,14 @@ \endgroup \expandafter\hvExternSetKeys\expandafter{\hv@extern@savePara}% \xdef\hv@extern@fullPath{\hv@extern@ExamplesDir\hvExternDateiname}% + \ifhv@extern@checkCode + \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} + \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 ...}% -- cgit v1.2.3