Skip to content

Unexpected blank line after the output (in REPL mode) #27

@fpantigny

Description

@fpantigny

I think that the latest version of pyluatex (2024/01/07 v0.6.2) adds an empty line at the end of the outputs (in REPL mode).

\documentclass{article}
\usepackage[executable=python.exe]{pyluatex}

\ExplSyntaxOn
\NewDocumentEnvironment{PythonREPL}{ } 
  {
    \PyLTVerbatimEnv
    \begin{pythonrepl}
  }
  {
    \end{pythonrepl}
    \directlua
      {
        tex.print("\\begin{verbatim}")
        tex.print(pyluatex.get_last_output())
        tex.print("-------------------- line~to~show~the~end") 
        tex.print("\\end{verbatim}")
      }
  }
\ExplSyntaxOff

\begin{document}

\begin{PythonREPL}
def fact(n) :
    p = 1
    for i in range(1,n+1):
            p = p*i
    return p

fact(5)
fact(13)
\end{PythonREPL}

\end{document}

Here is the output (in fact in verbatim font in the PDF).

>>> def fact(n) :
...     p = 1
...     for i in range(1,n+1):
...             p = p*i
...     return p
...
>>> fact(5)
120
>>> fact(13)
6227020800

--------------------line to show the end

The blank line before --------------------line to show the end is not expected (afaik).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions