diff options
author | Norbert Preining <norbert@preining.info> | 2022-06-06 03:02:07 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-06-06 03:02:07 +0000 |
commit | 89e8f58007e3fa8841a95b1e3d7efeacced6aed5 (patch) | |
tree | 5d9c98f1d4665ee3a9e459e8df5e4c66602140fc /macros/luatex/latex/pyluatex/pyluatex.lua | |
parent | 4695dd8cb1cb1d7ee3849e75dec28f742e802e56 (diff) |
CTAN sync 202206060302
Diffstat (limited to 'macros/luatex/latex/pyluatex/pyluatex.lua')
-rw-r--r-- | macros/luatex/latex/pyluatex/pyluatex.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/macros/luatex/latex/pyluatex/pyluatex.lua b/macros/luatex/latex/pyluatex/pyluatex.lua index efa80c75f4..0580d25a53 100644 --- a/macros/luatex/latex/pyluatex/pyluatex.lua +++ b/macros/luatex/latex/pyluatex/pyluatex.lua @@ -141,7 +141,7 @@ local function split_lines(str) return t end -function pyluatex.execute(code, auto_print, write, repl_mode) +function pyluatex.execute(code, auto_print, write, repl_mode, store) local full_code if auto_print then full_code = "print(str(" .. code .. "), end='')" @@ -159,14 +159,17 @@ function pyluatex.execute(code, auto_print, write, repl_mode) ignore_errors = pyluatex.ignore_errors } ) - last_code = split_lines(code) - last_output = split_lines(output) + local output_lines = split_lines(output) + if store then + last_code = split_lines(code) + last_output = output_lines + end if success or pyluatex.ignore_errors then if pyluatex.verbose or not success then log_output(output) end if write then - tex.print(last_output) + tex.print(output_lines) end else if not pyluatex.verbose then log_input(full_code) end @@ -195,7 +198,7 @@ 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) + local success = pyluatex.execute(code, false, false, env_repl_mode, true) if success or pyluatex.ignore_errors then return line:sub(s) else @@ -235,7 +238,7 @@ function pyluatex.run_file(path, write, repl_mode) elseif code:sub(-1) == "\n" then code = code:sub(0, -2) end - pyluatex.execute(code, false, write, repl_mode) + pyluatex.execute(code, false, write, repl_mode, true) else tex.sprint(err_cmd("File not found: " .. path)) end |