diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-03-05 15:27:40 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-03-05 15:28:57 +0100 |
commit | aeb11cea4eb1d0e6f68ad71cd178cd8636dcbf5f (patch) | |
tree | c05614e4d9b3e6fc82f3a677753580945b9a0a3f | |
parent | 6530bc447174cce2824e4a8a6fe6b21225010936 (diff) | |
download | pandoc-aeb11cea4eb1d0e6f68ad71cd178cd8636dcbf5f.tar.gz |
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.
-rw-r--r-- | src/Text/Pandoc/Writers/Markdown.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index 7dc472568..f665ec448 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -405,7 +405,11 @@ blockToMarkdown' opts (Plain inlines) = do not isPlain && beginsWithOrderedListMarker rendered then text $ escapeDelimiter rendered else contents - return $ contents' <> cr + -- escape if para starts with % + return $ + if isEnabled Ext_pandoc_title_block opts && take 1 rendered == "%" + then "\\" <> contents' <> cr + else contents' <> cr -- title beginning with fig: indicates figure blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) = blockToMarkdown opts (Para [Image attr alt (src,tit)]) |