diff options
author | Karl Berry <karl@freefriends.org> | 2022-10-26 20:00:20 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-10-26 20:00:20 +0000 |
commit | 95f466967f2f2c50c3a0013a49df25892d06b263 (patch) | |
tree | 57ed8ac8b09593f0ddb90e226aa81c6c0f752ff2 /Master/texmf-dist/tex/latex/docshots | |
parent | 26da0d28cc6538ba71aa39d9690aff5769440ae8 (diff) |
docshots (26oct22)
git-svn-id: svn://tug.org/texlive/trunk@64820 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/docshots')
-rw-r--r-- | Master/texmf-dist/tex/latex/docshots/docshots.sty | 101 |
1 files changed, 61 insertions, 40 deletions
diff --git a/Master/texmf-dist/tex/latex/docshots/docshots.sty b/Master/texmf-dist/tex/latex/docshots/docshots.sty index 10016c493da..56f47c48ec3 100644 --- a/Master/texmf-dist/tex/latex/docshots/docshots.sty +++ b/Master/texmf-dist/tex/latex/docshots/docshots.sty @@ -31,7 +31,8 @@ \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{docshots} -[2022-10-25 0.0.5 TeX Samples Next to Their PDF Snapshots in DTX] +[2022-10-26 0.2.0 TeX Samples Next to Their PDF Snapshots in DTX] + @@ -65,15 +66,18 @@ \RequirePackage{tikz} \RequirePackage{pgfopts} +\RequirePackage{ifluatex} +\RequirePackage{ifxetex} \def\docshots@log{} \pgfkeys{ /docshots/.cd, dtx/.store in=\docshots@dtx, log/.code=\def\docshots@log{log}, + nocrop/.code=\def\docshots@nocrop{}, lstinputlisting/.store in=\docshots@lstinputlisting, inputminted/.store in=\docshots@inputminted, tmpdir/.store in=\docshots@tmpdir, - tmpdir/.default=_docshots, + tmpdir/.default=_docshots\ifxetex-xe\else\ifluatex-lua\fi\fi, small/.store in=\docshots@small, tiny/.store in=\docshots@tiny, runs/.store in=\docshots@runs, @@ -96,15 +100,20 @@ } \ProcessPgfOptions{/docshots} -\iexec[\docshots@log,quiet]{\docshots@pdflatex\space --version}% +\iexec[\docshots@log,quiet]{"\docshots@pdflatex" --version}% + +\ifdefined\docshots@nocrop\else% + \iexec[\docshots@log,quiet]{"\docshots@pdfcrop" --version}% +\fi% -\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space --version}% +\iexec[\docshots@log,quiet]{"\docshots@gs" --version}% -\iexec[\docshots@log,quiet]{\docshots@gs\space --version}% +\iexec[null]{mkdir -p "\docshots@tmpdir/\jobname"}% -\iexec[null]{mkdir -p \docshots@tmpdir/\jobname}% +\RequirePackage{pdftexcmds} +\makeatletter\newcommand\docshots@mdfive[1]{\pdf@filemdfivesum{#1}}\makeatother -\newenvironment{docshot} +\makeatletter\newenvironment{docshot} {\VerbatimEnvironment\begin{VerbatimOut} {\docshots@tmpdir/\jobname/verbatim.tex}} {\end{VerbatimOut}% @@ -112,37 +121,48 @@ \iexec[null]{perl -i -0777pe "s/(\\n|^)\\x{25} /\\1/g" \docshots@tmpdir/\jobname/verbatim.tex}% \fi% - \def\hash{\pdfmdfivesum file - {\docshots@tmpdir/\jobname/verbatim.tex}}% + \def\hash{\docshots@mdfive{\docshots@tmpdir/\jobname/verbatim.tex}}% \IfFileExists{\docshots@tmpdir/\jobname/\hash.pdf} - {\message{docshots: won't render, the PDF already exists - (\docshots@tmpdir/\jobname/\hash.pdf)^^J}} - {\iexec[\docshots@log,quiet]{cp \docshots@tmpdir/\jobname/verbatim.tex - \docshots@tmpdir/\jobname/\hash.tex}% - \foreach \n in {1,...,\docshots@runs}{ - \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; - \docshots@pdflatex\space + {\message{docshots: Won't render, + the PDF '\docshots@tmpdir/\jobname/\hash.pdf' already exists^^J}} + {\iexec[\docshots@log,quiet]{cp "\docshots@tmpdir/\jobname/verbatim.tex" + "\docshots@tmpdir/\jobname/\hash.tex"}% + \foreach \n in {1,...,\docshots@runs}{% + \iexec[\docshots@log, + stdout=\docshots@tmpdir/\jobname/\hash.stdout, + exit=\docshots@tmpdir/\jobname/\hash.ret, + quiet,trace]{cd "\docshots@tmpdir/\jobname" && + "\docshots@pdflatex" -interaction=errorstopmode -halt-on-error -shell-escape - \hash.tex} - \message{docshots: pdflatex run no.\n^^J} + \hash.tex}% + \ifnum\n=1\else% + \message{docshots: pdflatex run no.\n^^J}% + \fi% \IfFileExists{\docshots@tmpdir/\jobname/after.sh} {\iexec[\docshots@log,quiet]{chmod a+x - \docshots@tmpdir/\jobname/after.sh} - \iexec[\docshots@log,quiet]{cd \docshots@tmpdir/\jobname; + "\docshots@tmpdir/\jobname/after.sh"} + \iexec[\docshots@log,quiet]{cd "\docshots@tmpdir/\jobname" && ./after.sh \n\space \hash\space \hash.tex}} {}}}% - \iexec[\docshots@log,quiet]{rm -f \docshots@tmpdir/\jobname/after.sh} + \iexec[\docshots@log,quiet]{rm -f "\docshots@tmpdir/\jobname/after.sh"} \IfFileExists{\docshots@tmpdir/\jobname/\hash.crop.pdf} - {\message{docshots: won't pdfcrop, the PDF already exists - (\docshots@tmpdir/\jobname/\hash.crop.pdf)^^J}} - {\iexec[\docshots@log,quiet]{\docshots@pdfcrop\space - --margins \docshots@margin\space - \docshots@tmpdir/\jobname/\hash.pdf - \docshots@tmpdir/\jobname/\hash.crop.pdf}}% + {\message{docshots: Won't pdfcrop, + the PDF '\docshots@tmpdir/\jobname/\hash.crop.pdf' + already exists^^J}} + {\ifdefined\docshots@nocrop + \iexec[\docshots@log,quiet]{cp + "\docshots@tmpdir/\jobname/\hash.pdf" + "\docshots@tmpdir/\jobname/\hash.crop.pdf"}% + \else% + \iexec[\docshots@log,quiet]{"\docshots@pdfcrop" + --margins 0 + "\docshots@tmpdir/\jobname/\hash.pdf" + "\docshots@tmpdir/\jobname/\hash.crop.pdf"}% + \fi}% \fvset{numbers=left,numbersep=3pt}% - \fvset{frame=leftline,framerule=.4pt,rulecolor=\color{gray}}% + \fvset{frame=leftline,framerule=.2pt,rulecolor=\color{gray}}% \fvset{samepage=true}% \fvset{baselinestretch=1}% \ifdefined\docshots@small% @@ -154,7 +174,8 @@ \begingroup% \par% \tikz[baseline=(a.north)] - \node (a) [draw=gray,inner sep=0] + \node (a) [draw=gray,inner sep=\docshots@margin, + line width=.2pt] {\includegraphics[width=\docshots@left] {\docshots@tmpdir/\jobname/\hash.crop.pdf}};% \hspace{\docshots@hspace}% @@ -172,20 +193,20 @@ \end{minipage}% \par% \endgroup% -} +}\makeatother -\newcommand\docshotPrerequisite[1]{ - \iexec[\docshots@log,quiet]{cp #1 \docshots@tmpdir/\jobname}% - \message{docshots: file #1 copied to - \docshots@tmpdir/\jobname/#1^^J}% -} +\makeatletter\newcommand\docshotPrerequisite[1]{ + \iexec[\docshots@log,quiet]{cp #1 "\docshots@tmpdir/\jobname"}% + \message{docshots: File '#1' copied to + '\docshots@tmpdir/\jobname/#1'^^J}% +}\makeatother -\newcommand\docshotAfter[1]{ +\makeatletter\newcommand\docshotAfter[1]{ \iexec[\docshots@log,quiet]{/bin/echo -n '\detokenize{#1}' - > \docshots@tmpdir/\jobname/after.sh}% - \message{docshots: file - \docshots@tmpdir/\jobname/after.sh created^^J}% -} + > "\docshots@tmpdir/\jobname/after.sh"}% + \message{docshots: File + '\docshots@tmpdir/\jobname/after.sh' created^^J}% +}\makeatother |