git.iko.soy/typeable/pandoc
on master help sign in
Shared.normalizeSpaces: strip off leading/trailing line breaks...
9862d7cJohn MacFarlane
src/Text/Pandoc/Shared.hs+4−2
@@ -355,8 +355,8 @@ orderedListMarkers (start, numstyle, numdelim) =
355 in map inDelim nums
355 in map inDelim nums
356
356
357-- | Normalize a list of inline elements: remove leading and trailing
357-- | Normalize a list of inline elements: remove leading and trailing
358−-- @Space@ elements, collapse double @Space@s into singles, and
358+-- @Space@, @LineBreak@, and @SoftBreak@ elements, collapse double
359−-- remove empty Str elements.
359+-- @Space@s into singles, and remove empty @Str@ elements.
360normalizeSpaces :: [Inline] -> [Inline]
360normalizeSpaces :: [Inline] -> [Inline]
361normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
361normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
362 where cleanup [] = []
362 where cleanup [] = []
@@ -368,6 +368,8 @@ normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
368
368
369isSpaceOrEmpty :: Inline -> Bool
369isSpaceOrEmpty :: Inline -> Bool
370isSpaceOrEmpty Space = True
370isSpaceOrEmpty Space = True
371+isSpaceOrEmpty SoftBreak = True
372+isSpaceOrEmpty LineBreak = True
371isSpaceOrEmpty (Str "") = True
373isSpaceOrEmpty (Str "") = True
372isSpaceOrEmpty _ = False
374isSpaceOrEmpty _ = False
373
375