diff options
Diffstat (limited to 'macros/latex/contrib/eolang/eolang.dtx')
-rw-r--r-- | macros/latex/contrib/eolang/eolang.dtx | 92 |
1 files changed, 66 insertions, 26 deletions
diff --git a/macros/latex/contrib/eolang/eolang.dtx b/macros/latex/contrib/eolang/eolang.dtx index 9e1bd88e9d..262c10f2ca 100644 --- a/macros/latex/contrib/eolang/eolang.dtx +++ b/macros/latex/contrib/eolang/eolang.dtx @@ -1,7 +1,7 @@ % \iffalse meta-comment % (The MIT License) % -% Copyright (c) 2021-2023 Yegor Bugayenko +% Copyright (c) 2021-2024 Yegor Bugayenko % % Permission is hereby granted, free of charge, to any person obtaining a copy % of this software and associated documentation files (the 'Software'), to deal @@ -50,7 +50,7 @@ %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{eolang} %<*package> -[2024-01-02 0.17.1 Formulas and Graphs for EO Programming Language] +[2024-01-11 0.18.0 Formulas and Graphs for EO Programming Language] %</package> %<*driver> \documentclass{ltxdoc} @@ -426,6 +426,19 @@ %</verb> %\fi +% \DescribeMacro{noshell} +% You may prohibit any interactions with the shell by using the |noshell| option. This may be helpful when you send your document +% for outside processing and want to make sure the compilation won't break due to shell errors: +%\iffalse +%<*verb> +%\fi +\begin{verbatim} +\usepackage[noshell]{eolang} +\end{verbatim} +%\iffalse +%</verb> +%\fi + % \section{More Examples} % The |phiquation| environment treats ends of line as signals to start @@ -757,7 +770,7 @@ % \end{macrocode} % We need \href{https://ctan.org/pkg/iexec}{iexec} for executing Perl scripts: % \begin{macrocode} -\RequirePackage{iexec} +\ifdefined\eolang@noshell\else\RequirePackage{iexec}\fi % \end{macrocode} % Then, we process package options: @@ -774,6 +787,7 @@ tmpdir/.default=_eolang\ifxetex-xe\else\ifluatex-lua\fi\fi, nocomments/.store in=\eolang@nocomments, anonymous/.store in=\eolang@anonymous, + noshell/.store in=\eolang@noshell, tmpdir } \ProcessPgfPackageOptions{/eolang} @@ -781,21 +795,29 @@ % Then, we make a directory where all temporary files will be kept: % \begin{macrocode} -\RequirePackage{shellesc} +\makeatletter +\ifdefined\eolang@noshell\else\RequirePackage{shellesc}\fi \IfFileExists {\eolang@tmpdir/\jobname} {\message{eolang: Temporary directory "\eolang@tmpdir/\jobname" already exists^^J}} - {% - \ifnum\ShellEscapeStatus=1% - \iexec[null]{mkdir -p "\eolang@tmpdir/\jobname"}% - \else% + { + \ifdefined\eolang@noshell \message{eolang: Temporary directory "\eolang@tmpdir/\jobname" - is not created, because -shell-escape is not set, and - it doesn't exist, most probably the compilation - will fail later^^J}% - \fi% + is not created, because of the "noshell" package option, + most probably the compilation will fail later^^J} + \else + \ifnum\ShellEscapeStatus=1 + \iexec[null]{mkdir -p "\eolang@tmpdir/\jobname"} + \else + \message{eolang: Temporary directory "\eolang@tmpdir/\jobname" + is not created, because -shell-escape is not set, and + it doesn't exist, most probably the compilation + will fail later^^J} + \fi + \fi } +\makeatother % \end{macrocode} % \begin{macro}{\eolang@lineno} @@ -840,6 +862,11 @@ % \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}: % \begin{macrocode} \makeatletter +\ifdefined\eolang@noshell + \message{eolang: Perl script is not going to be created, + at "\eolang@tmpdir/\jobname-phi.pl" because of the "noshell" + package option^^J} +\else \openin 15=\eolang@tmpdir/\jobname-phi.pl \ifeof 15 \message{eolang: Perl script is going to be created, @@ -850,7 +877,7 @@ $macro = $ARGV[0]; open(my $fh, '<', $ARGV[1]); my $tex; { local $/; $tex = <$fh>; } -print "% This file is auto-generated by 0.17.1\n"; +print "% This file is auto-generated by 0.18.0\n"; print '% There are ', length($tex), ' chars in the input: ', $ARGV[1], "\n"; print '% ---', "\n"; @@ -986,7 +1013,7 @@ $tex =~ s/\|{2,}/|/g; $tex =~ s/\|([^\|]+)\|/\\textnormal{\\texttt{\1}}{}/g; $tex =~ s/\{TEXT(\d+)\}/'\\text{' . @texts[$1] . '}';/ge; if ($macro eq 'phiq') { - print '$' if ($tex ne ''); + print '\(' if ($tex ne ''); } else { print '\begin{', $macro, "}\n"; if (not($align)) { @@ -1003,7 +1030,7 @@ if ($gathered and not($align)) { } print $tex; if ($macro eq 'phiq') { - print '$' if ($tex ne ''); + print '\)' if ($tex ne ''); } else { if (not($align)) { if ($gathered) { @@ -1023,6 +1050,7 @@ print '\endinput'; "\eolang@tmpdir/\jobname-phi.pl"^^J} \fi \closein 15 +\fi \makeatother % \end{macrocode} % \end{macro} @@ -1039,6 +1067,7 @@ print '\endinput'; % \begin{macro}{\eolang@ifabsent} % \changes{0.17.0}{2023/12/28}{A new supplementary \texttt{eolang@ifabsent} command added} +% \changes{0.18.0}{2024/01/09}{The \texttt{noshell} package option added in order to enable complete prohibition of shell interactions.} % Then, we define the |\eolang@ifabsent| command, which if a given file is absent, runs a processing command, otherwise just inputs it: % \begin{macrocode} \makeatletter @@ -1049,12 +1078,16 @@ print '\endinput'; \message{eolang: File "#1" already exists ^^J}% \input{#1}} {% - \ifnum\ShellEscapeStatus=1\else% - \message{eolang: The -shell-escape command line - option is not provided, most probably compilation - will fail now:^^J}% + \ifdefined\eolang@noshell% + \message{eolang: Shell processing is disabled^^J}% + \else% + \ifnum\ShellEscapeStatus=1\else% + \message{eolang: The -shell-escape command line + option is not provided, most probably compilation + will fail now:^^J}% + \fi% + #2% \fi% - #2% }% } \makeatother @@ -1070,15 +1103,15 @@ print '\endinput'; \def\hash{\eolang@mdfive {\eolang@tmpdir/\jobname/phiquation.tex}-\the\inputlineno}% \eolang@ifabsent - {\eolang@tmpdir/\jobname/\hash-post.tex} + {\eolang@tmpdir/\jobname/\hash-phiquation-post.tex} {% \iexec[null]{cp "\eolang@tmpdir/\jobname/phiquation.tex" - "\eolang@tmpdir/\jobname/\hash.tex"}% + "\eolang@tmpdir/\jobname/\hash-phiquation.tex"}% \message{Start parsing 'phi' at line no. \the\inputlineno^^J} - \iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-post.tex]{ + \iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-phiquation-post.tex]{ perl "\eolang@tmpdir/\jobname-phi.pl" '#1' - "\eolang@tmpdir/\jobname/\hash.tex" + "\eolang@tmpdir/\jobname/\hash-phiquation.tex" \ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi \ifdefined\eolang@phiSaveTo > \eolang@phiSaveTo\fi}% }% @@ -1123,6 +1156,7 @@ print '\endinput'; perl \eolang@tmpdir/\jobname-phi.pl 'phiq' "\eolang@tmpdir/\jobname/\hash-phiq.tex" \ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g' \fi}% + \message{eolang: Parsed `phiq' at line no. \the\inputlineno^^J}% }% \ifdefined\eolang@nodollar\else\catcode`\$\active\fi% }\makeatother @@ -1163,6 +1197,11 @@ print '\endinput'; % \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}: % \begin{macrocode} \makeatletter +\ifdefined\eolang@noshell +\message{eolang: Perl script is not going to be created + at "\eolang@tmpdir/\jobname-sodg.pl", because of the + "noshell" package option^^J} +\else \openin 15=\eolang@tmpdir/\jobname-sodg.pl \ifeof 15 \message{eolang: Perl script is going to be created, @@ -1448,6 +1487,7 @@ print '\endinput'; "\eolang@tmpdir/\jobname-sodg.pl"^^J} \fi \closein 15 +\fi \makeatother % \end{macrocode} % \end{macro} @@ -1590,11 +1630,11 @@ print '\endinput'; {\eolang@tmpdir/\jobname/\hash-sodg-post.tex} {% \iexec[null]{cp "\eolang@tmpdir/\jobname/sodg.tex" - "\eolang@tmpdir/\jobname/\hash.tex"}% + "\eolang@tmpdir/\jobname/\hash-sodg.tex"}% \message{eolang: Start parsing `sodg' at line no. \the\inputlineno^^J} \iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-sodg-post.tex]{ perl "\eolang@tmpdir/\jobname-sodg.pl" - "\eolang@tmpdir/\jobname/\hash.tex" + "\eolang@tmpdir/\jobname/\hash-sodg.tex" \ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi \ifdefined\eolang@sodgSaveTo > \eolang@sodgSaveTo\fi}% } |