diff options
author | Karl Berry <karl@freefriends.org> | 2023-06-14 20:14:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-06-14 20:14:27 +0000 |
commit | dee2ee7d27450ffe7825d33a38f47d9945b8fbf9 (patch) | |
tree | aafe63b60303eddf4cccdb726206323f84b1ed6b | |
parent | a789b7efd16779c91ec6bac929b4b9807c963c46 (diff) |
runcode (14jun23)
git-svn-id: svn://tug.org/texlive/trunk@67367 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/runcode/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/runcode/runcode.pdf | bin | 247080 -> 247859 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/runcode/runcode.tex | 39 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/runcode/runcode.sty | 26 |
4 files changed, 37 insertions, 30 deletions
diff --git a/Master/texmf-dist/doc/latex/runcode/README b/Master/texmf-dist/doc/latex/runcode/README index 4b757540427..010d8f44845 100644 --- a/Master/texmf-dist/doc/latex/runcode/README +++ b/Master/texmf-dist/doc/latex/runcode/README @@ -1,4 +1,4 @@ -LaTeX Package: runcode 2023/01/18 v1.8 +LaTeX Package: runcode 2023/06/13 v1.9 ---------------------------------------- The runcode package enables the execution of source code (e.g., R, Julia, Matlab, shell, Python, etc.) and embed the results in the pdf file diff --git a/Master/texmf-dist/doc/latex/runcode/runcode.pdf b/Master/texmf-dist/doc/latex/runcode/runcode.pdf Binary files differindex 405f5a26fd3..0a84593cf21 100644 --- a/Master/texmf-dist/doc/latex/runcode/runcode.pdf +++ b/Master/texmf-dist/doc/latex/runcode/runcode.pdf diff --git a/Master/texmf-dist/doc/latex/runcode/runcode.tex b/Master/texmf-dist/doc/latex/runcode/runcode.tex index 8751d4234ef..04c67fd5a2e 100644 --- a/Master/texmf-dist/doc/latex/runcode/runcode.tex +++ b/Master/texmf-dist/doc/latex/runcode/runcode.tex @@ -1,4 +1,4 @@ -% LaTeX Package: runcode 2023/01/18 v1.8 +% LaTeX Package: runcode 2023/06/13 v1.9 % % Copyright (C) 2020-2022 by Haim Bar and HaiYing Wang % @@ -49,7 +49,7 @@ package’s github repository, at \url{https://github.com/Ossifragus/runcode}. \end{abstract} \section{Installation} -\label{sec:org1037dff} +\label{sec:org8c6be84} You can simply put the runcode.sty file in the \LaTeX{} project folder. The server mode requires the @@ -65,9 +65,9 @@ compiling a \LaTeX{} document. \section{Usage} -\label{sec:org325e4fc} +\label{sec:org951dfd0} \subsection{Load the package:} -\label{sec:orgbccebff} +\label{sec:org516e8f6} \begin{minted}[]{latex} \usepackage[options]{runcode} \end{minted} @@ -139,7 +139,7 @@ be customized with \texttt{\textbackslash{}tcbset}, \end{minted} \subsection{Basic commands:} -\label{sec:org88340c8} +\label{sec:org917f9dc} \begin{itemize} \item \texttt{\textbackslash{}runExtCode\{Arg1\}\{Arg2\}\{Arg3\}[Arg4]} runs an external code. @@ -182,14 +182,15 @@ value \texttt{vbox} \end{itemize} \end{itemize} -\item \texttt{\textbackslash{}inln\{Arg1\}\{Arg2\}[Arg3]} is designed for simple calculations; it runs +\item \texttt{\textbackslash{}inln\{Arg1\}\{Arg2\}[Arg3][Arg4]} is designed for simple calculations; it runs one command (or a short batch) and displays the output within the text. \begin{itemize} \item \texttt{Arg1} is the executable program or programming language. \item \texttt{Arg2} is the source code. -\item \texttt{Arg3} is the output type. +\item \texttt{Arg3} is the output file name (optional); +\item \texttt{Arg4} is the output type. \begin{itemize} \item \texttt{inline} (or skipped or with empty value) = embed result in text. \item \texttt{vbox} = verbatim in a box. @@ -198,7 +199,7 @@ text. \end{itemize} \subsection{Language specific shortcuts:} -\label{sec:org591e87e} +\label{sec:org7b04bad} \href{https://julialang.org/}{Julia} \begin{itemize} @@ -211,7 +212,7 @@ text. \item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}runExtCode}. \end{itemize} -\item \texttt{\textbackslash{}inlnJulia[Arg1]\{Arg2\}[Arg3]} runs \href{https://julialang.org/}{Julia} +\item \texttt{\textbackslash{}inlnJulia[Arg1]\{Arg2\}[Arg3][Arg4]} runs \href{https://julialang.org/}{Julia} source code (\texttt{Arg2}) and displays the output in line. \begin{itemize} \item \texttt{Arg1} is optional and uses the \href{https://julialang.org/}{Julia} @@ -221,7 +222,7 @@ If the \href{https://julialang.org/}{Julia} source code is wrapped between "\texttt{```}" on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called. -\item \texttt{Arg3} has the same effect as that of the basic command \texttt{\textbackslash{}inln}. +\item \texttt{Arg3} and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}inln}. \end{itemize} \end{itemize} @@ -238,7 +239,7 @@ default. \item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}runExtCode}. \end{itemize} -\item \texttt{\textbackslash{}inlnMatLab[Arg1]\{Arg2\}[Arg3]} runs +\item \texttt{\textbackslash{}inlnMatLab[Arg1]\{Arg2\}[Arg3][Arg4]} runs \href{https://www.mathworks.com/products/matlab.html}{MatLab} source code (\texttt{Arg2}) and displays the output in line. \begin{itemize} @@ -252,7 +253,7 @@ code to run. If the code is wrapped between "```" on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called. -\item \texttt{Arg3} has the same effect as that of the basic command \texttt{\textbackslash{}inln}. +\item \texttt{Arg3} and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}inln}. \end{itemize} \end{itemize} @@ -268,7 +269,7 @@ will be written to a file on the disk and then be called. \item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}runExtCode}. \end{itemize} -\item \texttt{\textbackslash{}inlnPython[Arg1]\{Arg2\}[Arg3]} runs +\item \texttt{\textbackslash{}inlnPython[Arg1]\{Arg2\}[Arg3][Arg4]} runs \href{https://www.python.org/}{Python} source code (\texttt{Arg2}) and displays the output in line. \begin{itemize} @@ -279,7 +280,7 @@ If the \href{https://www.python.org/}{Python} source code is wrapped between "```" on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called. -\item \texttt{Arg3} has the same effect as that of the basic command \texttt{\textbackslash{}inln}. +\item \texttt{Arg3} and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}inln}. \end{itemize} \item \texttt{\textbackslash{}runPythonBatch[Arg1][Arg2]} runs an external \href{https://www.python.org/}{Python} code file in batch mode (without a @@ -308,7 +309,7 @@ installed via \texttt{pip3 install dill}. \item \texttt{Arg2}, \texttt{Arg3}, and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}runExtCode}. \end{itemize} -\item \texttt{\textbackslash{}inlnR[Arg1]\{Arg2\}[Arg3]} runs \href{https://www.r-project.org/}{R} +\item \texttt{\textbackslash{}inlnR[Arg1]\{Arg2\}[Arg3][Arg4]} runs \href{https://www.r-project.org/}{R} source code (\texttt{Arg2}) and displays the output in line. \begin{itemize} \item \texttt{Arg1} is optional and uses the \href{https://www.r-project.org/}{R} @@ -318,14 +319,16 @@ If the \href{https://www.r-project.org/}{R} source code is wrapped between "```" on both sides (as in the markdown grammar), then it will be implemented directly; otherwise the code will be written to a file on the disk and then be called. -\item \texttt{Arg3} has the same effect as that of the basic command \texttt{\textbackslash{}inln}. +\item \texttt{Arg3} and \texttt{Arg4} have the same effects as those of the basic command \texttt{\textbackslash{}inln}. \end{itemize} \end{itemize} \section{Revisions} -\label{sec:orgf884e2e} +\label{sec:orgdd95675} \begin{itemize} +\item v1.9, June 13, 2023: Update \texttt{\textbackslash{}inln} command; the optional \texttt{Arg3} is the output +file name and the optional \texttt{Arg4} is the output type. \item v1.8, January 18, 2023, add support to \href{https://ctan.org/pkg/listings?lang=en}{listings.} \item v1.7, August 20, 2022: changed the tmp/ folder to generated/ in order to conform with CTAN suggestions; renamed the troubleshooting file. @@ -344,7 +347,7 @@ code files, zero bytes in output files.) \end{itemize} \section{Contributing} -\label{sec:org0dce33b} +\label{sec:orge68f2c0} We welcome your contributions to this package by opening issues on GitHub and/or making a pull request. We also appreciate more example documents written using \texttt{runcode}. diff --git a/Master/texmf-dist/tex/latex/runcode/runcode.sty b/Master/texmf-dist/tex/latex/runcode/runcode.sty index ae859085b42..21e85f99082 100644 --- a/Master/texmf-dist/tex/latex/runcode/runcode.sty +++ b/Master/texmf-dist/tex/latex/runcode/runcode.sty @@ -4,7 +4,7 @@ % % This package is based on an ongoing work by Haim Bar and HaiYing Wang, and comments and questions are welcome! -\ProvidesPackage{runcode}[2023/01/18 runcode v1.8] +\ProvidesPackage{runcode}[2023/06/13 runcode v1.9] \newif\ifruncode % Change to \runcodefalse if you want to suspend code execution @@ -313,13 +313,17 @@ % \inln{Arg #1}{Arg #2}[Arg #3] is used to execute short source code % and embed resulting output. % Arg #1 is the executable program; -% Arg #2 is the source code -% Arg #3 is the type output (if skipped or with empty value the default type is +% Arg #2 is the source code; +% Arg #3 is the output file name (optional); +% Arg #4 is the type output (if skipped or with empty value the default type is % inline; vbox = verbatim in a box); -\NewDocumentCommand{\inln}{m m O{inline}}{\- - \stepcounter{codeOutput}\unskip - \unskip\setvalue{\tmpname}{\generated/\jobname_inln\thecodeOutput}\unskip\unskip\unskip +\NewDocumentCommand{\inln}{m m O{} O{inline}}{\- + \unskip + \ifthenelse{\isempty{#3}} + {\stepcounter{codeOutput}\unskip\unskip\setvalue{\tmpname}{\generated/\jobname_inln\thecodeOutput}\unskip\unskip\unskip} + {\unskip\setvalue{\tmpname}{\generated/#3}\unskip\unskip\unskip} + \unskip\unskip\unskip \ifruncode % cache mode - don't try to run the code, just get the previous results \IfBeginWith{#2}{```}{\ifruncode\immediate\write18{#1 > \tmpname.tex}\unskip\fi} {\newwrite\tempfile @@ -332,7 +336,7 @@ \fi % end cache mode \IfFileExists{\tmpname.tex} {\checkZeroBytes{\tmpname.tex}\unskip - \ifstrequal{#3}{vbox} + \ifstrequal{#4}{vbox} {\begin{tcolorbox} \ifminted\unskip \inputminted{text}{\tmpname.tex}\unskip @@ -354,7 +358,7 @@ {\runExtCode{#1}{#2}{#3}[#4]} } -\NewDocumentCommand{\inlnR}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","R","\tmpname.txt")'} m O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","R",f"```{rc0}```")'}{#2}[#3]}{\inln{#1}{#2}[#3]}} +\NewDocumentCommand{\inlnR}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","R","\tmpname.txt")'} m O{} O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","R",f"```{rc0}```")'}{#2}[#3][#4]}{\inln{#1}{#2}[#3][#4]}} \NewDocumentCommand{\runJulia}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","julia","#2")'} m m O{}} { @@ -364,7 +368,7 @@ {\runExtCode{#1}{#2}{#3}[#4]} } -\NewDocumentCommand{\inlnJulia}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","julia","\tmpname.txt")'} m O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","julia",f"```{rc0}```")'}{#2}[#3]}{\inln{#1}{#2}[#3]}} +\NewDocumentCommand{\inlnJulia}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","julia","\tmpname.txt")'} m O{} O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","julia",f"```{rc0}```")'}{#2}[#3][#4]}{\inln{#1}{#2}[#3][#4]}} \NewDocumentCommand{\runMatlab}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","matlab","#2")'} m m O{}} { @@ -374,7 +378,7 @@ {\runExtCode{#1}{#2}{#3}[#4]} } -\NewDocumentCommand{\inlnMatlab}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","matlab","\tmpname.txt")'} m O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","matlab",f"```{rc0}```")'}{#2}[#3]}{\inln{#1}{#2}[#3]}} +\NewDocumentCommand{\inlnMatlab}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","matlab","\tmpname.txt")'} m O{} O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","matlab",f"```{rc0}```")'}{#2}[#3][#4]}{\inln{#1}{#2}[#3][#4]}} \NewDocumentCommand{\runPython}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","python","#2")'} m m O{}} @@ -385,7 +389,7 @@ {\runExtCode{#1}{#2}{#3}[#4]} } -\NewDocumentCommand{\inlnPython}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","python","\tmpname.txt")'} m O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","python",f"```{rc0}```")'}{#2}[#3]}{\inln{#1}{#2}[#3]}} +\NewDocumentCommand{\inlnPython}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","python","\tmpname.txt")'} m O{} O{inline}}{\IfBeginWith{#2}{```}{\inln{python3 -c 'from talk2stat.talk2stat import client;rc0="""#2""";rc0=rc0.lstrip("```").rstrip("```");client("./","python",f"```{rc0}```")'}{#2}[#3][#4]}{\inln{#1}{#2}[#3][#4]}} %%%%%%%% |