gpoore / minted

minted is a LaTeX package that provides syntax highlighting using the Pygments library. Highlighted source code can be customized using fancyvrb.
1.74k stars 124 forks source link

Spaces in filenames and outputdir paths cause OS-dependent and option-dependent errors #276

Closed gpoore closed 5 days ago

gpoore commented 4 years ago

See https://github.com/gpoore/minted/issues/85#issuecomment-669696829 for original source.

Using filenames with spaces under Linux without outputdir seems to work fine (produces a correct PDF), but gives catchfile errors. Using outputdir paths with spaces with outputdir fails without producing a PDF. Some of this seems to involve ifplatform.sty running \ShellEsc around line 94, and quoting a path that is already quoted. outputdir doesn't auto-quote, so it requires manual quoting, and ifplatform.sty assumes no quoting. The manual quoting approach is what allows ~ expansion to work.

Windows is different. When there are spaces in the output directory path, outputdir needs to be quoted. When that is used with -file-line-error or -recorder, compilation fails. This is due to some operation that strips spaces from filenames.

It may be impossible to have a solution that works with ifplatform.sty (assumes no quoting under Linux, wraps with quotes) while also allowing ~ expansion. Alternatives may involve patching ifplatform.sty or using a different approach to OS detection.

yihuajack commented 3 years ago

I would add that this problem also occurs under Windows if the filename in braces is not quoted. The error information is

Package minted Error: Missing Pygments output; \inputminted was
probably given a file that does not exist--otherwise, you may need 
the outputdir package option, or may be using an incompatible build tool,
or may be using frozencache with a missing file.
muzimuzhi commented 11 months ago

Alternatives may involve patching ifplatform.sty or using a different approach to OS detection.

The expl3 programming environment provides \sys_if_platform_windows:TF {<true code>} {<false code>} and similar functions. See one possible emulation in https://github.com/wspr/will2e/issues/12#issuecomment-1724524879.

gpoore commented 5 days ago

This entire class of issues is eliminated in minted v3.0, which is available as a beta on GitHub and will have a final release soon.