Support hard_line_breaks in CommonMark reader.

This commit is contained in:
John MacFarlane 2017-08-08 13:30:53 -07:00
parent cf54c9b3c2
commit 54658b923a

View file

@ -54,6 +54,9 @@ readCommonMark opts s = return $
(if enabled Ext_emoji
then addEmojis
else id) $
(if enabled Ext_hard_line_breaks
then walk softToHardBreaks
else id) $
nodeToPandoc $ commonmarkToNode opts' exts s
where opts' = [ optSmart | enabled Ext_smart ]
exts = [ extStrikethrough | enabled Ext_strikeout ] ++
@ -61,6 +64,10 @@ readCommonMark opts s = return $
[ extAutolink | enabled Ext_autolink_bare_uris ]
enabled x = extensionEnabled x (readerExtensions opts)
softToHardBreaks :: Inline -> Inline
softToHardBreaks SoftBreak = LineBreak
softToHardBreaks x = x
addEmojis :: Pandoc -> Pandoc
addEmojis = walk go
where go (Str xs) = Str (convertEmojis xs)