-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Pandoc escapes characters over-aggressively when writing markdown #6259
Comments
There isn't a way to prevent this at the moment, but the escaping isn't "incorrect," only unnecessary. This is perfectly valid markdown.
which yields
and
which yields
In this particular case the escaping isn't necessary. Pandoc could probably be smarter about detecting such cases, but this isn't a bug. |
Thanks for the feedback. I changed the title, but I still think it's an open question regarding whether it is a bug for this one reason:
Thus, the readability of the produced markdown is questionable. |
I certainly agree that it would be better not to put in backslashes except when necessary. |
Depending on your use case, I've found a potential workaround for the time being. I'm using R Markdown to render
And then render it to
effectively preventing the markdown from getting backslash escaped, and giving me working footnotes for Jekyll. The key is to render it to
|
it does the same thing when converting from html to markdown, while it does not break things, it's truly an eyesore. is there a list for what it will be escaping so I can use sed/whatever to remove those added escape( |
|
@jayrobwilliams this seems unduly complex, given that pandoc has built in support for this style of footnotes. Have you tried |
I've pushed a change that should reduce unnecessary escapes for |
. + - are also impacted I think, also fenced-code-block are escaped unnecessarily it seems |
|
@jgm works perfectly! I totally missed in the documentation that you can append extensions to output formats; didn't event think to look for that since footnotes work natively with standard markdown. Thank you! |
I'm also having my issues with escaping of characters. I want my template to allow for inclusion of a PDF that is put before the PDF that is produced by the markdown. To have a simple solution (it might be optimized) i have two variables. One that is checked if the pages should be included, a second is the file name. (The use case here is to include the assignment that you are solving, just to explain the variable names ;))
I have the following code in the template, using the package pdfpages
However, if like shown above the filename contains an underscore, the intermediate .tex will have it escaped like This will fail to convert to pdf then. It works fine wihtout underscores. I have not yet found out how to either unescape this in latex (suboptimal I'd say) or (better) to not have pandoc escape this in the first place. Any idea? is it possible? I have tried to put the variable value into quotes, double quotes, ticks (` )... to no avail. Thanks |
There's an easy solution in your case @aslmx :
(This is the "raw attribute" and will cause the content to be passed to LaTeX unmodified.) |
Thanks. I was looking for something like this. I will try it and report if it does not work - i assume it works fine. thanks & br |
* erster Aufschlag für includepdf * beispiel.md: added comment for skipfirstpage * integrate changes as suggested in pandoc issue: jgm/pandoc#6259 (comment) * Modified readme.md to cater for the possibility to include ranges from PDF files * Forgot the exmaple block at begin of README.md - updated it m( * typo inf README.md - updated it m( Co-authored-by: Sebastian / sebbo <sebastian@1337lounge.de>
In case anyone finds this useful, it wasn't immediately obvious to me how to get @jayrobwilliams solution to work for multiline code, as I was initially trying to add the For example, a multiline quote placed as normal markdown gets collapse to one line...
turns to
But this works correctly after pandoc conversion...
|
For anyone looking for a simple compromise/work-around, if your goal is to just get readability you can use Shout out to this StackOverflow answer to the question Pandoc Markdown to Plain Text Formatting: https://stackoverflow.com/a/61622727 |
Suppose I want to use pandoc to convert between markdown flavors:
I get the following output with the
#1
escaped:How do I prevent pandoc from doing this?
Version Info
The text was updated successfully, but these errors were encountered: