summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/eolang/eolang.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/eolang/eolang.dtx')
-rw-r--r--macros/latex/contrib/eolang/eolang.dtx88
1 files changed, 61 insertions, 27 deletions
diff --git a/macros/latex/contrib/eolang/eolang.dtx b/macros/latex/contrib/eolang/eolang.dtx
index 9407f46eb6..9e1bd88e9d 100644
--- a/macros/latex/contrib/eolang/eolang.dtx
+++ b/macros/latex/contrib/eolang/eolang.dtx
@@ -50,7 +50,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{eolang}
%<*package>
-[2023-12-28 0.17.0 Formulas and Graphs for EO Programming Language]
+[2024-01-02 0.17.1 Formulas and Graphs for EO Programming Language]
%</package>
%<*driver>
\documentclass{ltxdoc}
@@ -84,16 +84,19 @@
% \maketitle
%
% \textbf{\color{red}NB!}
-% You must run \TeX{} processor with |--shell-escape| option
+% You must run \TeX{} processor with |-shell-escape| option
% and you must have \href{https://www.perl.org}{Perl} installed.
-% If you omit the |--shell-escape| option, the package will try
+% If you omit the |-shell-escape| option, the package will try
% to use cached files, if they exist. If they don't, compilation will
-% crash. Thus, when you must prepare your document for a compilation
-% without the |--shell-escape| option, run it locally with the option
-% and then package all files (including the files in the |_eolang| directory)
-% into a single ZIP archive.
+% fail. Thus, when you must prepare your document for a compilation
+% without the |-shell-escape| option, run it locally with the option provided
+% and then package all files (including the files in the |_eolang-*| directories)
+% into a single ZIP archive. It is advised to use |tmpdir| package option
+% in this case, in order to make the directory name not depend on the
+% \LaTeX{} engine.
%
-% If |--shell-escape| is set, this package doesn't work on Windows.
+% If |-shell-escape| is set, this package won't work on Windows, because
+% it uses POSIX command line interface.
% \section{Introduction}
%
@@ -778,12 +781,21 @@
% Then, we make a directory where all temporary files will be kept:
% \begin{macrocode}
-\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^^J}%
-\fi%
+\RequirePackage{shellesc}
+\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%
+ \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%
+ }
% \end{macrocode}
% \begin{macro}{\eolang@lineno}
@@ -805,7 +817,7 @@
% \end{macrocode}
% \end{macro}
-% \begin{macro}{eolang-phi.pl}
+% \begin{macro}{-phi.pl}
% \changes{0.0.2}{2022/10/21}{The symbols ``\texttt{[}'' and ``\texttt{]}'' replaced with ``\texttt{[[}'' and ``\texttt{]]}'' for abstract object brackets, because they conflicted with normal square brackets}
% \changes{0.0.2}{2022/10/21}{New symbol added for basket slots}
% \changes{0.0.2}{2022/10/21}{Parsing of the symbols ``\texttt{@},'' ``\texttt{\^{}},'' and ``\texttt{\&}'' enabled (\texttt{\char`\\varphi}, \texttt{\char`\\rho}, and \texttt{\char`\\sigma})}
@@ -828,11 +840,17 @@
% \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}:
% \begin{macrocode}
\makeatletter
-\begin{VerbatimOut}{\eolang@tmpdir/eolang-phi.pl}
+\openin 15=\eolang@tmpdir/\jobname-phi.pl
+\ifeof 15
+\message{eolang: Perl script is going to be created,
+ because it is absent at "\eolang@tmpdir/\jobname-phi.pl",
+ but if -shell-escape is not set, the compilation will
+ most likely fail now^^J}
+\begin{VerbatimOut}{\eolang@tmpdir/\jobname-phi.pl}
$macro = $ARGV[0];
open(my $fh, '<', $ARGV[1]);
my $tex; { local $/; $tex = <$fh>; }
-print "% This file is auto-generated by 0.17.0\n";
+print "% This file is auto-generated by 0.17.1\n";
print '% There are ', length($tex),
' chars in the input: ', $ARGV[1], "\n";
print '% ---', "\n";
@@ -909,9 +927,9 @@ $tex =~ s/([^\\{a-z0-9]|^)D>/\1\\Delta{}..>/g;
$tex =~ s/([^\\{a-z0-9]|^)L>/\1\\lambda{}..>/g;
$tex =~ s/"([^"]+)"/|"\1"|/g;
$tex =~ s/(^|(?<=[\s)(\]\[,.>\/]))([a-zA-Z][a-z0-9]+)(?=[\s)(\]\[,.-]|$)/|\2|/g;
-$tex =~ s/([^^_]|^)([0-9]+|\*)\/(\\?[a-z]+|\|[a-z]+\|)
+$tex =~ s/([^_^]|^)([0-9]+|\*)\/(\\?[a-z]+|\|[a-z]+\|)
(->|\.\.>|~>|:=|!->)/\1\\alpha_{\2}\\vert{}\3\\space{}\4/xg;
-$tex =~ s/([^^_]|^)([0-9]+|\*)
+$tex =~ s/([^_^]|^)([0-9]+|\*)
(->|\.\.>|~>|:=|!->)/\1\\alpha_{\2}\\space{}\3/xg;
if ($macro ne 'phiq') {
if (not $splitting) {
@@ -999,7 +1017,12 @@ if ($macro eq 'phiq') {
print '\endinput';
\end{VerbatimOut}
\message{eolang: File with Perl script
- '\eolang@tmpdir/eolang-phi.pl' saved^^J}%
+ '\eolang@tmpdir/\jobname-phi.pl' saved^^J}
+\else
+ \message{eolang: Perl script already exists at
+ "\eolang@tmpdir/\jobname-phi.pl"^^J}
+\fi
+\closein 15
\makeatother
% \end{macrocode}
% \end{macro}
@@ -1027,7 +1050,7 @@ print '\endinput';
\input{#1}}
{%
\ifnum\ShellEscapeStatus=1\else%
- \message{eolang: The --shell-escape command line
+ \message{eolang: The -shell-escape command line
option is not provided, most probably compilation
will fail now:^^J}%
\fi%
@@ -1053,7 +1076,7 @@ print '\endinput';
"\eolang@tmpdir/\jobname/\hash.tex"}%
\message{Start parsing 'phi' at line no. \the\inputlineno^^J}
\iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-post.tex]{
- perl "\eolang@tmpdir/eolang-phi.pl"
+ perl "\eolang@tmpdir/\jobname-phi.pl"
'#1'
"\eolang@tmpdir/\jobname/\hash.tex"
\ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi
@@ -1097,7 +1120,7 @@ print '\endinput';
\iexec[quiet,null]{cp "\eolang@tmpdir/\jobname/phiq.tex"
"\eolang@tmpdir/\jobname/\hash-phiq.tex"}%
\iexec[trace,stdout=\eolang@tmpdir/\jobname/\hash-phiq-post.tex]{
- perl \eolang@tmpdir/eolang-phi.pl 'phiq'
+ perl \eolang@tmpdir/\jobname-phi.pl 'phiq'
"\eolang@tmpdir/\jobname/\hash-phiq.tex"
\ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g' \fi}%
}%
@@ -1120,7 +1143,7 @@ print '\endinput';
% \end{macrocode}
% \end{macro}
-% \begin{macro}{eolang-sodg.pl}
+% \begin{macro}{-sodg.pl}
% \changes{0.0.2}{2022/10/24}{The Perl file now has a fixed name, which doesn't depend on the name of the TeX job. This file may be shared among jobs, no need to make it uniquely named.}
% \changes{0.1.0}{2022/10/26}{There are two Perl scripts now: one for \texttt{phiquation}, another one for \texttt{sodg}.}
% \changes{0.2.0}{2022/10/28}{The content of the \texttt{atom} and the \texttt{data} boxes is parsed automatically as formulas and numbers, respectively.}
@@ -1140,7 +1163,13 @@ print '\endinput';
% \href{https://ctan.org/pkg/fancyvrb}{fancyvrb}:
% \begin{macrocode}
\makeatletter
-\begin{VerbatimOut}{\eolang@tmpdir/eolang-sodg.pl}
+\openin 15=\eolang@tmpdir/\jobname-sodg.pl
+\ifeof 15
+\message{eolang: Perl script is going to be created,
+ because it is absent at "\eolang@tmpdir/\jobname-sodg.pl",
+ but if -shell-escape is not set, the compilation will
+ most likely fail now^^J}
+\begin{VerbatimOut}{\eolang@tmpdir/\jobname-sodg.pl}
sub num {
my ($i) = @_;
$i =~ s/(\+|-)\./\10./g;
@@ -1413,7 +1442,12 @@ print '% --- (' . (0+@cmds) . " lines)\n";
print '\endinput';
\end{VerbatimOut}
\message{eolang: File with Perl script
- '\eolang@tmpdir/eolang-sodg.pl' saved^^J}%
+ '\eolang@tmpdir/\jobname-sodg.pl' saved^^J}
+\else
+ \message{eolang: Perl script already exists at
+ "\eolang@tmpdir/\jobname-sodg.pl"^^J}
+\fi
+\closein 15
\makeatother
% \end{macrocode}
% \end{macro}
@@ -1559,7 +1593,7 @@ print '\endinput';
"\eolang@tmpdir/\jobname/\hash.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/eolang-sodg.pl"
+ perl "\eolang@tmpdir/\jobname-sodg.pl"
"\eolang@tmpdir/\jobname/\hash.tex"
\ifdefined\eolang@nocomments | perl -pe 's/\%.*(\\n|$)//g'\fi
\ifdefined\eolang@sodgSaveTo > \eolang@sodgSaveTo\fi}%