git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: escape initial % in a paragraph...

...if the `pandoc_title_blocks` extension is enabled. Otherwise in a document starting with a literal percent sign the first line is wrongly interpreted as a title. Closes #3454.

commitaeb11cea4eb1d0e6f68ad71cd178cd8636dcbf5f authorJohn MacFarlane <jgm@berkeley.edu> dateSun 5 Mar 2017, 15:27 (10 years ago) parent6530bc4
1 file changed+5−1
src/Text/Pandoc/Writers/Markdown.hs+5−1
src/Text/Pandoc/Writers/Markdown.hs+5−1
@@ -405,7 +405,11 @@ blockToMarkdown' opts (Plain inlines) = do
405405 not isPlain && beginsWithOrderedListMarker rendered
406406 then text $ escapeDelimiter rendered
407407 else contents
408− return $ contents' <> cr
408+ -- escape if para starts with %
409+ return $
410+ if isEnabled Ext_pandoc_title_block opts && take 1 rendered == "%"
411+ then "\\" <> contents' <> cr
412+ else contents' <> cr
409413-- title beginning with fig: indicates figure
410414blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =
411415 blockToMarkdown opts (Para [Image attr alt (src,tit)])