git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: Avoid wrapping that might start a list.

Or a blockquote or header. Closes #1013.

commit3670dda17c39fa9803851eba05add208c346c413 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 21 Jul 2014, 00:03 (12 years ago) parent0f970ed
1 file changed+5−1
src/Text/Pandoc/Writers/Markdown.hs+5−1
src/Text/Pandoc/Writers/Markdown.hs+5−1
@@ -658,7 +658,11 @@ getReference label (src, tit) = do
658658-- | Convert list of Pandoc inline elements to markdown.
659659inlineListToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc
660660inlineListToMarkdown opts lst =
661− mapM (inlineToMarkdown opts) lst >>= return . cat
661+ mapM (inlineToMarkdown opts) (avoidBadWraps lst) >>= return . cat
662+ where avoidBadWraps [] = []
663+ avoidBadWraps (Space:Str (c:cs):xs)
664+ | c `elem` "-*+>" = Str (' ':c:cs) : avoidBadWraps xs
665+ avoidBadWraps (x:xs) = x : avoidBadWraps xs
662666
663667escapeSpaces :: Inline -> Inline
664668escapeSpaces (Str s) = Str $ substitute " " "\\ " s