git.iko.soy/typeable/pandoc
on master help sign in
Support `hard_line_breaks` in CommonMark reader.
54658b9John MacFarlane
src/Text/Pandoc/Readers/CommonMark.hs+7
@@ -54,6 +54,9 @@ readCommonMark opts s = return $
54 (if enabled Ext_emoji
54 (if enabled Ext_emoji
55 then addEmojis
55 then addEmojis
56 else id) $
56 else id) $
57+ (if enabled Ext_hard_line_breaks
58+ then walk softToHardBreaks
59+ else id) $
57 nodeToPandoc $ commonmarkToNode opts' exts s
60 nodeToPandoc $ commonmarkToNode opts' exts s
58 where opts' = [ optSmart | enabled Ext_smart ]
61 where opts' = [ optSmart | enabled Ext_smart ]
59 exts = [ extStrikethrough | enabled Ext_strikeout ] ++
62 exts = [ extStrikethrough | enabled Ext_strikeout ] ++
@@ -61,6 +64,10 @@ readCommonMark opts s = return $
61 [ extAutolink | enabled Ext_autolink_bare_uris ]
64 [ extAutolink | enabled Ext_autolink_bare_uris ]
62 enabled x = extensionEnabled x (readerExtensions opts)
65 enabled x = extensionEnabled x (readerExtensions opts)
63
66
67+softToHardBreaks :: Inline -> Inline
68+softToHardBreaks SoftBreak = LineBreak
69+softToHardBreaks x = x
70+
64addEmojis :: Pandoc -> Pandoc
71addEmojis :: Pandoc -> Pandoc
65addEmojis = walk go
72addEmojis = walk go
66 where go (Str xs) = Str (convertEmojis xs)
73 where go (Str xs) = Str (convertEmojis xs)