summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/hvextern/hvextern.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-04-27 19:38:45 +0000
committerKarl Berry <karl@freefriends.org>2022-04-27 19:38:45 +0000
commita1ed5651a5e3f5c5f92b9c4c21baea8538dfa77b (patch)
tree345e9e2b3052f3cd4d92283d535987938e77725c /Master/texmf-dist/tex/latex/hvextern/hvextern.sty
parent0af0f41700900cdfd791389cb63c3b57ce4d957f (diff)
hvextern (27apr22)
git-svn-id: svn://tug.org/texlive/trunk@63159 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/hvextern/hvextern.sty')
-rw-r--r--Master/texmf-dist/tex/latex/hvextern/hvextern.sty208
1 files changed, 150 insertions, 58 deletions
diff --git a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty
index 201f4ef7b11..9e3fbea8c0e 100644
--- a/Master/texmf-dist/tex/latex/hvextern/hvextern.sty
+++ b/Master/texmf-dist/tex/latex/hvextern/hvextern.sty
@@ -11,11 +11,11 @@
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
-\def\hvexternFileversion{0.19}
-\ProvidesFile{hvextern}[2022/04/23 v\hvexternFileversion: package for running external documents (HV)]
+\def\hvexternFileversion{0.20}
+\ProvidesFile{hvextern}[2022/04/27 v\hvexternFileversion: package for running external documents (HV)]
\RequirePackage{shellesc,xkeyval,graphicx,marginnote,fancyvrb,tikz,listings,ifplatform}
-\RequirePackage{tcolorbox}
+\RequirePackage{tcolorbox,xparse}
\tcbuselibrary{skins,breakable}
\ifwindows
@@ -29,8 +29,8 @@
\newcounter{hv@extern@runs}
\newcounter{@@@runs}
\newsavebox\hv@extern@box
-\newlength\LineWidth
-\AtBeginDocument{\setlength\LineWidth{\dimexpr\linewidth-2\fboxsep-2\fboxrule}}
+\newlength\hv@LineWidth
+\AtBeginDocument{\setlength\hv@LineWidth{\dimexpr\linewidth-2\fboxsep-2\fboxrule}}
\newlength\hv@extern@mpwidth \setlength\hv@extern@mpwidth{\z@}
\define@key{hv}{progpath}{\def\hv@extern@progpath{#1}}
@@ -49,6 +49,7 @@
\define@key{hv}{cropmargin}[2]{\def\hv@extern@cropmargin{#1 }}
\define@key{hv}{mpwidth}[0pt]{\setlength\hv@extern@mpwidth{#1}}
\define@key{hv}{ext}[tex]{\def\hv@extern@ext{.#1}}
+\define@boolkey{hv}[hv@extern@]{redirect}[true]{}
\define@boolkey{hv}[hv@extern@]{usefancyvrb}[true]{}
\define@boolkey{hv}[hv@extern@]{showFilename}[true]{}
\define@boolkey{hv}[hv@extern@]{code}[true]{}
@@ -93,6 +94,7 @@
code=false,% show Code
crop=false,% erzeugte PDF "croppen"
compiler=pdflatex,% zu verwendener Compiler
+ redirect=false,% write output into a file *.txt
grfOptions={},% Optionen der einzubindenden Grafik
lstOptions={},% Optionen für das Listing
BGpreamble=black!12,% Backgroundcolor for preamble
@@ -134,20 +136,19 @@
\gdef\DoubleNumChar{##}
}
-\def\run@hv@extern@cleanup#1{\expandafter\run@hv@extern@cleanup@i#1,\@nil}
-\def\run@hv@extern@cleanup@i#1,#2\@nil{%
- \def\hv@next{}%
- \ifx\relax#1\relax
- \else
- \hv@typeout{>>>> Delete file \hv@extern@ExamplesDir\hvExternDateiname.#1}%
- \ShellEscape{\hv@rm \hv@extern@ExamplesDir\hvExternDateiname.#1}%
- \ifx\relax#2\relax\else
- \def\hv@next{\run@hv@extern@cleanup@i#2,\@nil}%
- \fi
- \fi
- \hv@next
-}
-
+\ExplSyntaxOn
+\NewDocumentCommand\run@hv@extern@cleanup{ m }
+ {
+ \clist_map_inline:nn {#1}{\ShellEscape{\hv@rm \hv@extern@ExamplesDir\hvExternDateiname.##1}}
+ }
+\NewDocumentCommand\run@hv@extern@sequenceList{ m }
+ {
+ \clist_map_inline:nn {#1}{%
+ \ShellEscape{\hv@extern@progpath##1\space\hvExternDateiname}
+ %\hv@typeout{>>>> sequencerun: ##1}
+ }
+ }
+\ExplSyntaxOff
\lstset{belowskip=0pt,aboveskip=0pt}% global
\tcbset{breakable,left=2pt,right=2pt,top=2pt,bottom=2pt,boxsep=0pt}
@@ -162,25 +163,109 @@
\newcounter{hv@example@counter}
-\newcommand\extern@ExampleType[5]{%
+\newcommand\hv@extern@ExampleType[5]{%
\@namedef{#1@initTextFancy}{\edef\FancyVerbStartString{#2}\edef\FancyVerbStopString{#3}}% text
\@namedef{#1@initPreambleFancy}{\edef\FancyVerbStartString{#4}\edef\FancyVerbStopString{#5}}% code
\@namedef{#1@initText}{linerange={#2}-{#3},includerangemarker=false}% text
\@namedef{#1@initPreamble}{linerange={#4}-{#5},includerangemarker=false}% code
}% ^^to prevent problems with lua comments
-\input{hvextern-mp.cfg}
-\input{hvextern-tex.cfg}
-\input{hvextern-latex.cfg}
-\input{hvextern-context.cfg}
-\input{hvextern-py.cfg}
-\input{hvextern-pl.cfg}
-\input{hvextern-lua.cfg}
+%%------------------ the config part --------------------
+%\input{hvextern-mp.cfg}
+%---- MP
+\hv@extern@ExampleType{mp}
+ {beginfig(1)}
+ {endfig;}
+ {\perCent StartVisiblePreamble}
+ {\perCent StopVisiblePreamble}
+
+\def\hv@extern@runMP#1#2#3#4{% path compiler file extension
+ \hv@typeout{>>>> running #1#2 #3#4}%
+ \ShellEscape{#1#2\space -tex=tex\space #3#4}%
+ \hv@typeout{>>>> running #1tex #3}%
+ \ShellEscape{#1tex\space "\string\input\space epsf\string\relax\string\nopagenumbers\string\epsfbox{#3.1}\string\bye"}%
+ \hv@typeout{>>>> running #1dvips #3}%
+ \ShellEscape{#1dvips\space -j\space -E\space -o\space #3.eps\space epsf.dvi}%
+ \hv@typeout{>>>> running #1epstopdf #3}%
+ \ShellEscape{#1epstopdf\space #3.eps}%
+}
+
+%---- TeX
+%\input{hvextern-tex.cfg}
+\hv@extern@ExampleType{tex}
+ {\perCent StartBody}
+ {\string\bye}
+ {\perCent StartVisiblePreamble}
+ {\perCent StopVisiblePreamble}
+
+\def\hv@extern@runTEX#1#2#3#4{% path compiler file extension
+ \hv@typeout{>>>> running #1#2 #3#4}%
+ \ShellEscape{#1tex\space #3#4}%
+ \hv@typeout{>>>> running #1dvips #3}%
+ \ShellEscape{#1dvips\space #3.dvi}%
+ \hv@typeout{>>>> running ps2pdf #3.ps}%
+ \ShellEscape{#1ps2pdf\space -dAutoRotatePages=/None\space -dALLOWPSTRANSPARENCY\space #3.ps}%
+}
+
+%---- LaTeX
+%\input{hvextern-latex.cfg}
+\hv@extern@ExampleType{latex}%
+ {\string\begin\string{document\string}}%
+ {\string\end\string{document\string}}%
+ {\perCent StartVisiblePreamble}%
+ {\perCent StopVisiblePreamble}%
+
+% only for the sequence latex->dvips->ps2pdf
+\def\hv@extern@runLATEX#1#2#3#4{% path-compiler-file-extension
+ \hv@typeout{>>>> running #1#2 #3#4}%
+ \ShellEscape{#1#2\space #3#4}%
+ \hv@typeout{>>>> running #1dvips #3}%
+ \ShellEscape{#1dvips\space #3.dvi}%
+ \hv@typeout{>>>> running ps2pdf #3.ps}%
+ \ShellEscape{#1ps2pdf\space -dAutoRotatePages=/None\space -dALLOWPSTRANSPARENCY\space #3.ps}%
+}
+
+%---- ConTeXt
+%\input{hvextern-context.cfg}
+\hv@extern@ExampleType{context}
+ {\string\starttext}
+ {\string\stoptext}
+ {\perCent StartVisiblePreamble}
+ {\perCent StopVisiblePreamble}
+
+%---- Python
+%\input{hvextern-py.cfg}
+\hv@extern@ExampleType{py}
+ {\NumChar StartVisibleMain}
+ {\NumChar StopVisibleMain}
+ {\NumChar StartVisiblePreamble}
+ {\NumChar StopVisiblePreamble}
+
+
+%---- Perl
+%\input{hvextern-pl.cfg}
+\hv@extern@ExampleType{pl}
+ {\NumChar StartVisibleMain}
+ {\NumChar StopVisibleMain}
+ {\NumChar StartVisiblePreamble}
+ {\NumChar StopVisiblePreamble}
+
+
+%---- Lua
+%\input{hvextern-lua.cfg}
+\hv@extern@ExampleType{lua}
+ {--StartVisibleMain}
+ {--StopVisibleMain}
+ {--StartVisiblePreamble}
+ {--StopVisiblePreamble}
+
+
+%%%--------------------------------- end config part ------------------
%%
%% [#1]: Optionen #2: Dateiname
%%
-\newenvironment{ErstelleGrafik}[2][]{%
+\newenvironment{externalDocument}[2][]{%
\xdef\hvExternDateiname{#2-\arabic{hv@example@counter}}%
\setkeys{hv}{#1}% \begin
\expandafter\IfFileExists\expandafter{\hv@extern@ExamplesDir\hvExternDateiname.pdf}{}{%
@@ -196,33 +281,41 @@
\global\stepcounter{hv@example@counter}%
\endgroup
\ifhv@extern@force
- \hv@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@typeout{>>>> running mpost \hvExternDateiname\hv@extern@ext}%
- \hv@extern@runMP{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}%
- \or %1
- \hv@typeout{>>>> running tex \hvExternDateiname\hv@extern@ext}%
- \hv@extern@runTEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}%
- \or %2
- \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}%
- \hv@extern@runLATEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}%
- \else
- \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}%
- \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext}%
+ \ifx\hv@extern@runsequence\@empty
+ \hv@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@typeout{>>>> running mpost \hvExternDateiname\hv@extern@ext}%
+ \hv@extern@runMP{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}%
+ \or %1
+ \hv@typeout{>>>> running tex \hvExternDateiname\hv@extern@ext}%
+ \hv@extern@runTEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}%
+ \or %2
+ \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}%
+ \hv@extern@runLATEX{\hv@extern@progpath}{\hv@extern@compiler}{\hvExternDateiname}{\hv@extern@ext}%
+ \else
+ \hv@typeout{>>>> running \hv@extern@compiler~ \hvExternDateiname\hv@extern@ext}%
+ \ifhv@extern@redirect
+ \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext\space > \hvExternDateiname.txt}%
+ \else
+ \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname\hv@extern@ext}%
+ \fi
+ \fi
+ \addtocounter{@@@runs}{-1}%
+ \repeat
+ \hv@typeout{>>> ... done}%
+ \ifhv@extern@biber
+ \ShellEscape{biber \hvExternDateiname}% NAch biber nochmal latex
+ \ShellEscape{\hv@extern@progpath\hv@extern@compiler\space\hvExternDateiname}%
\fi
- \addtocounter{@@@runs}{-1}%
- \repeat
- \hv@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
+ \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
+ \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}%
@@ -302,7 +395,8 @@
\hspace{5pt}}\hspace*{-5pt}%
\else
\expandafter\@for\expandafter\next\expandafter:\expandafter=\hv@extern@pages\do{%
- \expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]{\hv@extern@ExamplesDir\hvExternDateiname}%
+ \expandafter\includegraphics\expandafter[\hv@extern@grfOptions,page=\next]%
+ {\hv@extern@ExamplesDir\hvExternDateiname}%
\hspace{5pt}}\hspace*{-5pt}%
\fi
\ifx\hv@extern@caption\@empty\else\caption{\hv@extern@caption}\fi
@@ -322,11 +416,9 @@
\noindent\VerbatimInput{\hv@extern@ExamplesDir\hvExternDateiname.txt}
\fi
\fi
- \ifhv@extern@force\run@hv@extern@cleanup{\hv@extern@cleanup}\fi% cleanup
+ \ifhv@extern@force\expandafter\run@hv@extern@cleanup\expandafter{\hv@extern@cleanup}\fi% cleanup
}
\stepcounter{hv@example@counter}%
%
-\let\externalDocument\ErstelleGrafik
-\let\endexternalDocument\endErstelleGrafik
%%
\endinput