texlive[65588] Master/texmf-dist: runcode (19jan23)

commits+karl at tug.org commits+karl at tug.org
Thu Jan 19 22:03:06 CET 2023


Revision: 65588
          http://tug.org/svn/texlive?view=revision&revision=65588
Author:   karl
Date:     2023-01-19 22:03:05 +0100 (Thu, 19 Jan 2023)
Log Message:
-----------
runcode (19jan23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/runcode/README
    trunk/Master/texmf-dist/doc/latex/runcode/runcode.pdf
    trunk/Master/texmf-dist/doc/latex/runcode/runcode.tex
    trunk/Master/texmf-dist/tex/latex/runcode/runcode.sty

Modified: trunk/Master/texmf-dist/doc/latex/runcode/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/runcode/README	2023-01-19 21:02:50 UTC (rev 65587)
+++ trunk/Master/texmf-dist/doc/latex/runcode/README	2023-01-19 21:03:05 UTC (rev 65588)
@@ -1,4 +1,4 @@
-LaTeX Package: runcode 2022/08/20 v1.7
+LaTeX Package: runcode 2023/01/18 v1.8
 ----------------------------------------
 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

Modified: trunk/Master/texmf-dist/doc/latex/runcode/runcode.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/runcode/runcode.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/runcode/runcode.tex	2023-01-19 21:02:50 UTC (rev 65587)
+++ trunk/Master/texmf-dist/doc/latex/runcode/runcode.tex	2023-01-19 21:03:05 UTC (rev 65588)
@@ -1,4 +1,4 @@
-% LaTeX Package: runcode 2022/08/20 v1.7
+% LaTeX Package: runcode 2023/01/18 v1.8
 % 
 % Copyright (C) 2020-2022 by Haim Bar and HaiYing Wang
 % 
@@ -49,7 +49,7 @@
 \end{abstract}
 
 \section{Installation}
-\label{sec:org7e4c2ed}
+\label{sec:org1037dff}
 You can simply put the runcode.sty file in the \LaTeX{} project folder.
 
 The server mode requires the
@@ -65,9 +65,9 @@
 
 
 \section{Usage}
-\label{sec:org2d22735}
+\label{sec:org325e4fc}
 \subsection{Load the package:}
-\label{sec:orgbfab84d}
+\label{sec:orgbccebff}
 \begin{minted}[]{latex}
 \usepackage[options]{runcode}
 \end{minted}
@@ -77,13 +77,17 @@
 \begin{itemize}
 \item \texttt{cache}: use cached results.
 
-\item \texttt{julia}: start server for \href{https://julialang.org/}{Julia} (requires
-\href{https://pypi.org/project/talk2stat/}{talk2stat}).
+\item \texttt{fvextra}: use the \href{https://ctan.org/pkg/fvextra}{fvextra} package to show code.
 
-\item \texttt{matlab}: start server for
-\href{https://www.mathworks.com/products/matlab.html}{MatLab} (requires
-\href{https://pypi.org/project/talk2stat/}{talk2stat}).
+\item \texttt{julia}: start server for \href{https://julialang.org/}{Julia} (requires \href{https://pypi.org/project/talk2stat/}{talk2stat}).
 
+\item \texttt{listings}: use the \href{https://ctan.org/pkg/listings?lang=en}{listings} package to show code.
+
+\item \texttt{matlab}: start server for \href{https://www.mathworks.com/products/matlab.html}{MatLab} (requires \href{https://pypi.org/project/talk2stat/}{talk2stat}).
+
+\item \texttt{minted}: use the \href{https://ctan.org/pkg/minted}{minted} package to show code (requires the \href{https://pygments.org/}{pygments} package).
+This is the default option.
+
 \item \texttt{nominted}: use the \href{https://ctan.org/pkg/fvextra}{fvextra} package
 instead of the \href{https://ctan.org/pkg/minted}{minted} package to show
 code (this does not require the \href{https://pygments.org/}{pygments}
@@ -117,6 +121,14 @@
 \setminted[R]{linenos, frame=single, bgcolor=lightgray, breaklines=true}
 \end{minted}
 
+Similarly, \href{https://ctan.org/pkg/fvextra}{fvextra} and \href{https://ctan.org/pkg/listings?lang=en}{listings} packages can be customized through the \texttt{\textbackslash{}lstset}
+and \texttt{\textbackslash{}fvset} commands, respectively, e.g.: 
+
+\begin{minted}[]{latex}
+\lstset{basicstyle=\large, frame=single}
+\fvset{fontsize=\small, linenos=true, frame=single}
+\end{minted}
+
 The outputs from executing codes are displayed in
 \href{https://ctan.org/pkg/tcolorbox?lang=en}{tcolorbox}, so the style can
 be customized with \texttt{\textbackslash{}tcbset},
@@ -127,7 +139,7 @@
 \end{minted}
 
 \subsection{Basic commands:}
-\label{sec:org1b11cd1}
+\label{sec:org88340c8}
 \begin{itemize}
 \item \texttt{\textbackslash{}runExtCode\{Arg1\}\{Arg2\}\{Arg3\}[Arg4]} runs an external code.
 
@@ -144,9 +156,7 @@
 \end{itemize}
 
 \item \texttt{\textbackslash{}showCode\{Arg1\}\{Arg2\}[Arg3][Arg4]} shows the source code, using
-\href{https://ctan.org/pkg/minted}{minted} for a pretty layout or
-\href{https://ctan.org/pkg/fvextra}{fvextra} (if
-\href{https://pygments.org/}{pygments} is not installed).
+\href{https://ctan.org/pkg/minted}{minted} (requires \href{https://pygments.org/}{pygments}), \href{https://ctan.org/pkg/fvextra}{fvextra}, or \href{https://ctan.org/pkg/listings?lang=en}{listings}.
 
 \begin{itemize}
 \item \texttt{Arg1} is the programming language.
@@ -188,7 +198,7 @@
 \end{itemize}
 
 \subsection{Language specific shortcuts:}
-\label{sec:org154f922}
+\label{sec:org591e87e}
 \href{https://julialang.org/}{Julia}
 
 \begin{itemize}
@@ -314,8 +324,9 @@
 
 
 \section{Revisions}
-\label{sec:orgf446497}
+\label{sec:orgf884e2e}
 \begin{itemize}
+\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.
 \item v1.6, August 10, 2022: stop only configured/running servers; a new
@@ -333,7 +344,7 @@
 \end{itemize}
 
 \section{Contributing}
-\label{sec:org0730899}
+\label{sec:org0dce33b}
 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}.

Modified: trunk/Master/texmf-dist/tex/latex/runcode/runcode.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/runcode/runcode.sty	2023-01-19 21:02:50 UTC (rev 65587)
+++ trunk/Master/texmf-dist/tex/latex/runcode/runcode.sty	2023-01-19 21:03:05 UTC (rev 65588)
@@ -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}[2022/08/20 runcode v1.7]
+\ProvidesPackage{runcode}[2023/01/18 runcode v1.8]
 
 \newif\ifruncode
 % Change to \runcodefalse if you want to suspend code execution
@@ -12,10 +12,23 @@
 \DeclareOption{run}{\runcodetrue}
 \DeclareOption{cache}{\runcodefalse}
 
+% Choose the package for code typesetting. The default is minted.
+% The other two options are listings and fvextra. For backward compatibility,
+% it is possible to use nominted, in which case fvextra is used.
 \newif\ifminted
 \mintedtrue
-\DeclareOption{nominted}{\mintedfalse}
+\DeclareOption{nominted}{\mintedfalse} 
+\DeclareOption{minted}{\mintedtrue\fvextrafalse\listingsfalse}
 
+\newif\iflistings
+\listingsfalse
+\DeclareOption{listings}{\listingstrue\mintedfalse\fvextrafalse}
+
+\newif\iffvextra
+\fvextrafalse
+\DeclareOption{fvextra}{\fvextratrue\mintedfalse\listingsfalse}
+
+
 \newif\ifreducedspace
 \reducedspacefalse
 \DeclareOption{reducedspace}{\reducedspacetrue}
@@ -136,13 +149,19 @@
 \usepackage{xparse}
 \usepackage{xstring}
 
-% Use minted if it is loaded; otherwise use fvextra
+% Use minted by default; but the user can change to listings or fvextra.
 \ifminted
 \usepackage[cache=false]{minted}
 \setminted{fontsize=\footnotesize,breaklines=true} % minted default
 \else
+\iflistings
+\usepackage{listings}
+\lstset{escapeinside=`',columns=fixed, extendedchars=true, basicstyle=\ttfamily\small, frame = lines}
+\else
 \usepackage{fvextra}
+\fvset{fontsize=\footnotesize, breaklines}
 \fi
+\fi
 
 \newcommand{\generated}{generated}
 \immediate\write18{mkdir -p \generated}
@@ -179,7 +198,7 @@
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
-% \showCode prints the source code, using minted for a pretty layout
+% \showCode prints the source code, using minted or listings for a pretty layout
 % Arg #1 is the programming language,
 % Arg #2 is the source file name,
 % Args #3 and #4 are the first and last line to show (optional).
@@ -194,8 +213,12 @@
       \vspace{-\baselineskip}
     \fi
     \else
-    \VerbatimInput[fontsize=\footnotesize,linenos=true,frame=single,breaklines]{#2}
+      \iflistings
+        \lstinputlisting[language=#1]{#2}
+      \else
+    \VerbatimInput{#2}
     \fi
+    \fi
   }{
     \ifminted
     \inputminted[firstline=#3, lastline=#4, firstnumber=1]{#1}{#2}
@@ -204,8 +227,12 @@
       \vspace{-\baselineskip}
     \fi
     \else
-    \VerbatimInput[fontsize=\footnotesize,linenos=true,frame=single,breaklines, firstline=#3, lastline=#4, firstnumber=1]{#2}
+      \iflistings
+      \lstinputlisting[language=#1,firstline=#3, lastline=#4]{#2}
+      \else
+    \VerbatimInput[firstline=#3, lastline=#4, firstnumber=1]{#2}
     \fi
+    \fi
   } 
   }{
     \textcolor{red}{\textbf{showCode: File #2 does not exist!}}
@@ -261,9 +288,12 @@
     {\begin{tcolorbox}
         \ifminted\unskip
           \inputminted{text}{\tmpname}\unskip
+        \else\iflistings\unskip
+          \lstinputlisting{\tmpname}\unskip
         \else\unskip
-        \VerbatimInput[fontsize=\footnotesize,breaklines]{\tmpname}\unskip
+        \VerbatimInput{\tmpname}\unskip
         \fi
+        \fi
       \end{tcolorbox}}
     {\unskip\ifstrequal{#2}{inline}
       {\unskip\input{\tmpname}\unskip}
@@ -306,11 +336,14 @@
         {\begin{tcolorbox}
         \ifminted\unskip
           \inputminted{text}{\tmpname.tex}\unskip
+        \else\unskip\iflistings\unskip
+          \lstinputlisting{\tmpname.tex}\unskip
         \else\unskip
-        \VerbatimInput[fontsize=\footnotesize,breaklines]{\tmpname.tex}\unskip
+        \VerbatimInput{\tmpname.tex}\unskip
         \fi
+        \fi
       \end{tcolorbox}}
-    {\unskip\input{\tmpname.tex}\unskip}}
+    {\unskip{\input{\tmpname.tex}}\unskip}}
     {\textcolor{red}{\textbf{Output file \tmpname~ not found}}}}
 
 \NewDocumentCommand{\runR}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","R","#2")'} m m O{}}
@@ -321,7 +354,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;client("./","R","#2")'}{#2}[#3]}{\inln{#1}{#2}[#3]}}
+\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{\runJulia}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","julia","#2")'} m m O{}}
 { 
@@ -331,7 +364,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;client("./","julia","#2")'}{#2}[#3]}{\inln{#1}{#2}[#3]}}
+\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{\runMatlab}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","matlab","#2")'} m m O{}}
 { 
@@ -341,7 +374,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;client("./","matlab","#2")'}{#2}[#3]}{\inln{#1}{#2}[#3]}}
+\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{\runPython}{O{python3 -c 'from talk2stat.talk2stat import client; client("./","python","#2")'} m m O{}}
@@ -352,7 +385,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;client("./","python","#2")'}{#2}[#3]}{\inln{#1}{#2}[#3]}}
+\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]}}
 
 
 %%%%%%%%



More information about the tex-live-commits mailing list.