summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/pyluatex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-12-31 03:04:33 +0000
committerNorbert Preining <norbert@preining.info>2022-12-31 03:04:33 +0000
commit276038a22b002640c158178010b146bf9287b31b (patch)
tree0b9ace4bd052e023f56ef77d2eeb24c4a5442ade /macros/luatex/latex/pyluatex
parent844019377157163b461e0fd4a66592e61963a530 (diff)
CTAN sync 202212310304
Diffstat (limited to 'macros/luatex/latex/pyluatex')
-rw-r--r--macros/luatex/latex/pyluatex/README.md13
-rw-r--r--macros/luatex/latex/pyluatex/pyluatex.lua7
-rw-r--r--macros/luatex/latex/pyluatex/pyluatex.pdfbin82658 -> 82203 bytes
-rw-r--r--macros/luatex/latex/pyluatex/pyluatex.sty2
-rw-r--r--macros/luatex/latex/pyluatex/pyluatex.tex17
5 files changed, 19 insertions, 20 deletions
diff --git a/macros/luatex/latex/pyluatex/README.md b/macros/luatex/latex/pyluatex/README.md
index c93a3b8c8b..06ae0a714d 100644
--- a/macros/luatex/latex/pyluatex/README.md
+++ b/macros/luatex/latex/pyluatex/README.md
@@ -32,15 +32,17 @@ $\sqrt{371} = \py{math.sqrt(371)}$
\randint{2}{5}
\end{document}
```
-**Note:** PyLuaTeX starts Python 3 using the command `python3` by default.
-If `python3` does not start Python 3 on your system, find the correct command
-and replace `\usepackage{pyluatex}` with `\usepackage[executable=<your python command>]{pyluatex}`.
-For example, `\usepackage[executable=python.exe]{pyluatex}`.
2\. Compile using LuaLaTeX (shell escape is required)
```
lualatex -shell-escape example.tex
```
+
+**Note:** PyLuaTeX starts Python 3 using the command `python3` by default.
+If `python3` does not start Python 3 on your system, find the correct command
+and replace `\usepackage{pyluatex}` with `\usepackage[executable=<your python command>]{pyluatex}`.
+For example, `\usepackage[executable=python.exe]{pyluatex}`.
+
**Note:** Running LaTeX with the shell escape option enabled allows arbitrary code to be
executed. For this reason, it is recommended to compile trusted documents only.
@@ -49,9 +51,6 @@ executed. For this reason, it is recommended to compile trusted documents only.
* Python 3
* Linux, macOS or Windows
-The automated tests currently use TeX Live 2022 and Python 3.8+ on
-Ubuntu 20.04, macOS Big Sur 11 and Windows Server 2022.
-
## License
[LPPL 1.3c](http://www.latex-project.org/lppl.txt) for LaTeX code and
[MIT license](https://opensource.org/licenses/MIT) for Python and Lua code.
diff --git a/macros/luatex/latex/pyluatex/pyluatex.lua b/macros/luatex/latex/pyluatex/pyluatex.lua
index 0580d25a53..2b53bd7713 100644
--- a/macros/luatex/latex/pyluatex/pyluatex.lua
+++ b/macros/luatex/latex/pyluatex/pyluatex.lua
@@ -41,6 +41,7 @@ local env_end = nil
local env_lines = nil
local parent_env = nil
local env_repl_mode = false
+local env_success = true
local last_code = nil
local last_output = nil
@@ -183,7 +184,7 @@ function pyluatex.execute(code, auto_print, write, repl_mode, store)
end
function pyluatex.print_env()
- if last_output ~= nil then
+ if last_output ~= nil and (env_success or pyluatex.ignore_errors) then
tex.print(last_output)
end
end
@@ -198,8 +199,8 @@ local function record_line(line)
table.insert(env_lines, code_in_line)
end
local code = table.concat(env_lines, "\n")
- local success = pyluatex.execute(code, false, false, env_repl_mode, true)
- if success or pyluatex.ignore_errors then
+ env_success = pyluatex.execute(code, false, false, env_repl_mode, true)
+ if env_success or pyluatex.ignore_errors then
return line:sub(s)
else
return env_end .. err_cmd("Python error (see above)") .. line:sub(e + 1)
diff --git a/macros/luatex/latex/pyluatex/pyluatex.pdf b/macros/luatex/latex/pyluatex/pyluatex.pdf
index c7710f6f78..5f5e096b87 100644
--- a/macros/luatex/latex/pyluatex/pyluatex.pdf
+++ b/macros/luatex/latex/pyluatex/pyluatex.pdf
Binary files differ
diff --git a/macros/luatex/latex/pyluatex/pyluatex.sty b/macros/luatex/latex/pyluatex/pyluatex.sty
index 6e287e5100..02ac9d5f6c 100644
--- a/macros/luatex/latex/pyluatex/pyluatex.sty
+++ b/macros/luatex/latex/pyluatex/pyluatex.sty
@@ -9,7 +9,7 @@
%% version 2005/12/01 or later.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{pyluatex}[2022/06/05 v0.5.0 Execute Python code on the fly]
+\ProvidesPackage{pyluatex}[2022/12/30 v0.5.1 Execute Python code on the fly]
\RequirePackage{expl3}
\ExplSyntaxOn
diff --git a/macros/luatex/latex/pyluatex/pyluatex.tex b/macros/luatex/latex/pyluatex/pyluatex.tex
index 366a7ae8da..56782fcf19 100644
--- a/macros/luatex/latex/pyluatex/pyluatex.tex
+++ b/macros/luatex/latex/pyluatex/pyluatex.tex
@@ -15,7 +15,7 @@
\usepackage{url}
\title{The \emph{pyluatex} package}
\author{Tobias Enderle\\\url{https://github.com/tndrle/PyLuaTeX}}
-\date{v0.5.0 (2022/06/05)}
+\date{v0.5.1 (2022/12/30)}
\begin{document}
\maketitle
\raggedright
@@ -54,18 +54,20 @@ $\sqrt{371} = \py{math.sqrt(371)}$
\randint{2}{5}
\end{document}
\end{tcblisting}
-\textbf{Note:} PyLuaTeX starts Python 3 using the command \inlcode|python3| by default.
-If \inlcode|python3| does not start Python 3 on your system, find the correct command
-and replace \inlcode|\usepackage{pyluatex}| with \inlcode|\usepackage[executable=<your python command>]{pyluatex}|.
-For example, \inlcode|\usepackage[executable=python.exe]{pyluatex}|.
\item Compile using Lua\LaTeX{} (shell escape is required)
\begin{tcblisting}{breakable,listing only,
size=fbox,colframe=black!8,boxrule=3pt,colback=black!8}
lualatex -shell-escape example.tex
\end{tcblisting}
+\end{enumerate}
+\textbf{Note:} PyLuaTeX starts Python 3 using the command \inlcode|python3| by default.
+If \inlcode|python3| does not start Python 3 on your system, find the correct command
+and replace \inlcode|\usepackage{pyluatex}| with \inlcode|\usepackage[executable=<your python command>]{pyluatex}|.
+For example, \inlcode|\usepackage[executable=python.exe]{pyluatex}|.
+
\textbf{Note:} Running \LaTeX{} with the shell escape option enabled allows arbitrary code to be
executed. For this reason, it is recommended to compile trusted documents only.
-\end{enumerate}
+
\subsection{Further Examples}
The folder \inlcode|example| contains additional example documents:
\begin{itemize}
@@ -200,9 +202,6 @@ in your environment definition, e.g.
\item Python 3
\item Linux, macOS or Windows
\end{itemize}
-The automated tests currently use TeX Live 2022 and Python 3.8+ on
-Ubuntu 20.04, macOS Big Sur 11 and Windows Server 2022.
-
\section{Typesetting Code}
Sometimes, in addition to having Python code executed and the output written to your document, you also want to show the code itself in your document.
PyLuaTeX does not offer any macros or environments that directly typeset code.