-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrectly escaped backslashes in the value of a fenced code block's attributes #8506
Comments
l. 431 of Text.Pandoc.Readers.LaTeX kvs <- mapM (\(k,v) -> (k,) <$>
stringToLaTeX TextString v) keyvalAttr The Looking at the history I see commit 0b3b774 and commit a55fb5f which fixed #6742. |
It's tough to know how to deal with this context. If we do escape, we'll run into problems like yours from people who want to use TeX commands in these attributes. If we don't, we'll run into problems like #6742. Perhaps we should have solved #6742 by telling the user to backslash escape the |
With regards to whether the underscore escaping was necessary, it appears that it was, as \begin{lstlisting}[caption={some_code.c}]
code here
\end{lstlisting} gives the following output
when compiled with |
Pandoc supports multiple output formats. So, your code block with attribute The pandoc types don't currently give us a way to represent the difference you're suggesting between a "passthrough attribute" and a "textual attribute." |
Drat. In that case, it would make more sense to me if pandoc didn't modify the fields at all then, because if pandoc escapes then the user loses a lot of freedom in those attributes. If the user has to escape, then all those things are still possible, the user just has to take escaping into account. |
It goes both ways, though: escaping gives the user the freedom to generate multiple output formats from the same source document. I see both arguments, and I'm not sure right now what the best solution would be. |
I think that would be true if pandoc did more to map specific attribute names to specific output fields (other than startFrom). Adding a caption field only adds a caption to a latex document, at least in my experimentation (mostly with HTML). But because the attribute field name is (or at least seems to be) particular to the output format, I think it makes more sense to assume that the attribute value is going to be parsed by that format as well. |
I don't think there's anything about a |
In general, some escaping needs to be done for attribute values. In HTML/XML formats, for example, all attribute values have |
After some more experimentation with the only formats that use attributes (LaTeX, Docx, pptx, Ms, and HTML, at least, according to the docs), latex is indeed the only one that uses the |
I came across this same issue with trying to control the fontsize in a verbatim block that wrapped:
There's no way I can think of to escape this back so that you get the right values in the output. That is, escaping is a one way function. |
I'm trying to use
pandoc
in order to convert a markdown file to a pdf, and I ran into an issue where it garbled the formatting attributes of code blocks. I narrowed the issue down topandoc
going from markdown to texfiles in general.When using the command
pandoc -s --listings tmp.md -o tmp.tex
to convert the following markdownto a
.tex
file in version2.9.2.1
, I get the expected output ofas the start of the listing. However, on version
2.17.1.1
, it startswhere it completely misinterprets the backslashes in the formatting instructions. I've tried reproducing on the online, but I couldn't figure out how to enable the
--listings
option, which is key to getting the values to actually show up.The text was updated successfully, but these errors were encountered: