If I convert a single quote '
from HTML to Markdown, it is automatically escaped:
% echo "'" | pandoc -f html -t markdown
\'
I'd like it to output without the slash, as it makes text with contractions rather much harder to read.
I thought this might be due to the "all_symbols_escapable" option, but it still happens, even when I turn that off:
% echo "'" | pandoc -f html -t markdown-all_symbols_escapable
\'
It isn't a problem, however, for markdown_strict:
% echo "'" | pandoc -f html -t markdown_strict
'
Any suggestions? I'd like to use the default Pandoc markdow with the options tweaked, or report this as a bug if it's not what others expect.
Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.
An extension can be enabled by adding +EXTENSION to the format name and disabled by adding -EXTENSION . For example, --from markdown_strict+footnotes is strict Markdown with footnotes enabled, while --from markdown-footnotes-pipe_tables is pandoc's Markdown without footnotes or pipe tables.
Generating PDF from Markdown with Pandoc There are actually two steps involved in converting a Markdown file to a PDF file: The Markdown source file is converted to a LaTeX source file. Pandoc invokes the pdflatex or xelatex or other TeX command and converts the . tex source file to a PDF file.
Escaping is related to pandoc's smart
extensions. This extension converts single quotes to the typographically correct opening/closing single quote or apostrophe when appropriate. This becomes most clear when looking at HTML output that uses only ASCII characters:
% echo "'hello'" | pandoc -f markdown -t html --ascii
<p>‘hello’</p>
% echo "let's" | pandoc -f markdown -t html --ascii
<p>let’s</p>
This smart treatment of quotes can be disabled on a per-case basis by escaping the character
% echo "let\'s" | pandoc -f markdown -t html --ascii
<p>let's</p>
or by disabling the smart extension for markdown:
% echo "let's" | pandoc -f markdown-smart -t html --ascii
<p>let's</p>
So whenever pandoc sees a '
character in HTML, it assumes that this character was chosen intentionally over the more correct single quote, and thus ensures that it won't be treated in a "smart" way when read back from Markdown.
The solution is thus to tell pandoc that it should ignore these details and will write Markdown as if it would not be subjected to the smart treatment of quotes:
% echo "'" | pandoc -f html -t markdown-smart
'
The smart extension is already disabled when using markdown_strict
, which is why you got the desired behavior in that case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With