Open h4ck3rm1k3 opened 6 years ago
codeblock
isn't a standard LaTeX macro. Presumably this is some kind of custom verbatim environment? In any case, pandoc doesn't know it's a verbatim environment, and that's the issue here.
You can work around this by adding something like this before your content:
\renewenvironment{codeblock}{\begin{verbatim}}{\end{verbatim}}
codeblock is defined here in the source https://github.com/cplusplus/draft/blob/master/source/macros.tex#L390
have tried to extract a test case with the workaround https://github.com/h4ck3rm1k3/pandoc/blob/master/test/tex/codeblocksetup.tex
So applying this idea
\renewenvironment{codeblock}{\begin{verbatim}}{\end{verbatim}}
\begin{codeblock}
std::for_each
\end{codeblock}
gives
Error at "source" (line 4, column 17):
unexpected end of input
expecting \end{verbatim}
\end{codeblock}
Errors here https://github.com/h4ck3rm1k3/pandoc/blob/master/test/tex/codeblocksetup.tex.err
Now using verbatim directly works.
\begin{codeblock}
\begin{verbatim}
std::for_each
\end{verbatim}
\end{codeblock}
PS: this is also occurring in itemdecl
and bnf
the macro definitions for these are
This did not occur in 1.19.2.4 on debian
Looks like we need better support for \lstnewenvironment
from listings.
I'm running into this issue trying to convert https://github.com/chapel-lang/chapel/blob/master/spec/spec.tex with pandoc.
Is there a workaround for this issue? I'm happy to modify the definitions for things like \begin{codeblock}
in the example above, but I really don't want to modify all of the locations where it is used because there are rather a lot of them. (Sure, I could probably modify those with pandoc somehow... but not if it just dies with a syntax error.)
But, at the end of the day, I also want to have these listing environments turn into rst code blocks specifying a language. How can I modify the LaTeX input so that it is reasonable to accomplish that (maybe with a filter)? The example4.tex example doesn't seem to use code syntax highlighting.
I have never used pandoc before trying to do this task, so forgive me if the answer is somehow obvious. Thanks!
I tried to use the verbatim
package as a workaround:
\newenvironment{codeblock}%
{\endgraf\verbatim}%
{\endverbatim}
while with this I am able to get LaTeX to render the document without using lstnewenvironment, pandoc still gets tripped up when the code includes an _
.
Any update on this? I'm also running into this issue...
@jonsneyers what version of pandoc are you using? With 2.19.2, it handles this fine (with the small workaround suggested by @mppf - @mppf, I don't think underlines cause a problem any more, see below):
% pandoc -f latex -t native
\newenvironment{codeblock}%
{\endgraf\verbatim}%
{\endverbatim}
\begin{codeblock}
\begin{verbatim}
std::for_each
\end{verbatim}
\end{codeblock}
^D
[ CodeBlock
( "" , [] , [] )
"std::for_each"
]
Found originally on this file algorithms.tex https://github.com/cplusplus/draft/blob/master/source/algorithms.tex#L334
Test case now here https://github.com/h4ck3rm1k3/pandoc/blob/master/test/tex/tex-code-block-escape.tex Error message https://github.com/h4ck3rm1k3/pandoc/blob/master/test/tex/tex-code-block-escape.tex.err
There are other errors like this in that project