git.iko.soy/typeable/pandoc
on master help sign in
Shared.normalizeSpaces: strip off leading/trailing line breaks...

...not just spaces.

commit9862d7c359ce4f9e5f89c4ee5131e0f051c134d2 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 10 Mar 2017, 20:21 (10 years ago) parentd037c50
1 file changed+4−2
src/Text/Pandoc/Shared.hs+4−2
src/Text/Pandoc/Shared.hs+4−2
@@ -355,8 +355,8 @@ orderedListMarkers (start, numstyle, numdelim) =
355355 in map inDelim nums
356356
357357-- | Normalize a list of inline elements: remove leading and trailing
358−-- @Space@ elements, collapse double @Space@s into singles, and
359−-- remove empty Str elements.
358+-- @Space@, @LineBreak@, and @SoftBreak@ elements, collapse double
359+-- @Space@s into singles, and remove empty @Str@ elements.
360360normalizeSpaces :: [Inline] -> [Inline]
361361normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
362362 where cleanup [] = []
@@ -368,6 +368,8 @@ normalizeSpaces = cleanup . dropWhile isSpaceOrEmpty
368368
369369isSpaceOrEmpty :: Inline -> Bool
370370isSpaceOrEmpty Space = True
371+isSpaceOrEmpty SoftBreak = True
372+isSpaceOrEmpty LineBreak = True
371373isSpaceOrEmpty (Str "") = True
372374isSpaceOrEmpty _ = False
373375