Closed sorsted closed 10 months ago
Thank you for using the Markdown package for TeX and for describing your problem to us.
You didn't tell us the command you used to compile your document. However, line 3 in your log says "restricted \write18 enabled". This tells me that you did not enable shell access, as described in the user manual. Try typesetting your document with shell access enabled as follows and see if the error persists:
$ pdflatex --shell-escape test.tex
No, I didn’t use --shell-escape
, and I don’t think I’m going to, as I don’t know what external programs the package wants to use (I trust you, but not with my life, sorry 😉). In that case, I will probably have to stick to LuaTeX, I guess.
In any case, some of us don’t like using --shell-escape
, so perhaps you could try to find a way to work around this with pdfTeX? And if not, perhaps the error message could be made more clear? I had no idea that --shell-escape
was necessary, and I believe this has not always been the case, right? I seem to recall having used markdown
in the past with pdfTeX without it. In fact, most LaTeX users (like myself) have barely heard of --shell-escape
and probably never used it. A lot of us are used to compiling LaTeX by pressing a button in our editor of choice.
No, I didn’t use
--shell-escape
, and I don’t think I’m going to, as I don’t know what external programs the package wants to use (I trust you, but not with my life, sorry 😉).
I understand. The package uses the shell to execute Lua code. A common solution to your problem is to run pdfTeX in a Docker container, see the example in the README. This way, you can grant pdfTeX shell access without exposing any data other than the document that you wish to compile.
In any case, some of us don’t like using
--shell-escape
, so perhaps you could try to find a way to work around this with pdfTeX?
The Markdown package uses Lua to parse markdown text. Since Lua is unavailable in pdfTeX, the only alternative to using the shell seems to be the rewrite of the markdown parser from Lua to TeX. However, this would be time-consuming and the resulting code would be more difficult to maintain as well as substantially slower. Therefore, there has not been much interest in pursuing this direction.
If you know about other alternatives to using the shell in pdfTeX, please let me know.
And if not, perhaps the error message could be made more clear?
It definitely should, thanks for bringing this to our attention. Currently, the execution of Lua code and all error handling is delegated to the lt3luabridge package, which uses the \sys_get_shell:nnNTF
expl3 function in pdfTeX to determine whether the shell is available and to either use the shell or report an error:
\msg_new:nnnn
{ luabridge }
{ level-disabled }
{
Shell~escape~seems~to~be~disabled
}
{
You~may~need~to~run~TeX~with~the~--shell-escape~or~the~
--enable-write18~flag,~or~write~shell_escape=t~in~the~texmf.cnf~file.
}
However, from your report it seems that the function \sys_get_shell:nnNTF
fails to properly handle the case where the shell escape is disabled/restricted and does not produce a human-readable error.
I opened a ticket for your issue in https://github.com/Witiko/lt3luabridge/issues/22.
I had no idea that
--shell-escape
was necessary, and I believe this has not always been the case, right? I seem to recall having used markdown in the past with pdfTeX without it.
Strange! The Markdown package for TeX has required the use of --shell-escape
in TeX engines other than LuaTeX since its first release in 2016.
In fact, most LaTeX users (like myself) have barely heard of
--shell-escape
and probably never used it. A lot of us are used to compiling LaTeX by pressing a button in our editor of choice.
There are many LaTeX packages that require --shell-escape
such as minted for source code highlighting, asymptote for creating vector graphics, and imakeidx for building indices. LaTeX editors such as Overleaf enable --shell-escape
by default, which may be why some TeX users are unaware of it.
@sorsted: After #372, compiling your example document test.tex
with pdfLaTeX produces a human-readable error with instructions how to fix it:
! Package markdown Error: Shell escape is restricted
For immediate help type H <return>.
...
l.12 \end{markdown}
? H
You may need to run TeX with the --shell-escape or the --enable-write18 flag,
or write shell_escape=t in the texmf.cnf file.
?
This update will be released in Markdown 3.3.0, which will be included in TeX Live 2024.
I tried compiling the following document with pdfTeX:
The result was an emergency stop and the error message displayed below. It compiles just fine with LuaTeX.
System information: I am using TeX Live 2023 (installed yesterday, October 22) on Windows 10. I got the same error message with TeX Live 2022, which was why I installed the 2023 version yesterday.