Skip to content

Commit

Permalink
Markdown writer: escape initial % in a paragraph...
Browse files Browse the repository at this point in the history
...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.
  • Loading branch information
jgm committed Mar 5, 2017
1 parent 6530bc4 commit aeb11ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Text/Pandoc/Writers/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down

0 comments on commit aeb11ce

Please sign in to comment.