Closed marcin-serwin closed 11 months ago
Version 2.7 reads the verbatim argument for \mintinline
differently than previous versions, and does not support line breaks within the verbatim argument. The \foo
command is passing bar^^Mbaz
to \mintinline
, where the ^^M
is a newline. You could define \foo
with \NewDocumentCommand{\foo}{v}
(v
, not +v
). Or you could replace the ^^M
with spaces before passing it on to \mintinline
.
You could define
\foo
with\NewDocumentCommand{\foo}{v}
(v
, not+v
). Or you could replace the^^M
with spaces before passing it on to\mintinline
.
Neither of these solutions will output the newlines though. I want the PDF output to be
bar
baz
not
bar baz
This should do what you want. \mintinline
isn't intended for code with newlines, though, so there's no guarantee that this won't stop working again in the future. A proper solution would probably involve wrapping #1
in a minted
environment with something involving \scantokens
, since the minted
environment is intended for multi-line code.
\NewDocumentCommand{\foo}{+v}{%
\begingroup
\let\VerbEnv\Verbatim
\let\endVerbEnv\endVerbatim
\mintinline{latex}{#1}%
\endgroup}
Thank you for the help. The proposed solution is still not ideal, since now \foo
ends current paragraph and starts another so it's no longer "inline", but I can work around it.
If you're trying to use it inline within paragraphs, you probably want something like this:
\makeatletter
\NewDocumentCommand{\foo}{+v}{%
\begingroup
\let\VerbEnv\Verbatim
\let\endVerbEnv\endVerbatim
\mintinline{latex}{#1}%
\endgroup\@doendpe}
\makeatother
In version 2.6 the following code was working fine
but in version 2.7 it results in the error below