git.iko.soy/typeable/pandoc
on master help sign in
More efficient implementation of nowrap in Pretty.
commit142c29d90827f81bcccad35ed39f3669298b8961 authorJohn MacFarlane <fiddlosopher@gmail.com> dateWed 8 Feb 2012, 08:32 (15 years ago) parent11e1e2b
1 file changed+4−4
src/Text/Pandoc/Pretty.hs+4−4
src/Text/Pandoc/Pretty.hs+4−4
@@ -72,7 +72,7 @@ module Text.Pandoc.Pretty (
7272 )
7373
7474where
75−import Data.Sequence (Seq, fromList, (<|), singleton)
75+import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex)
7676import Data.Foldable (toList)
7777import Data.List (intercalate)
7878import Data.Monoid
@@ -408,9 +408,9 @@ beforeNonBlank d = Doc $ singleton (BeforeNonBlank d)
408408
409409-- | Makes a 'Doc' non-reflowable.
410410nowrap :: Doc -> Doc
411−nowrap doc = Doc $ fromList $ map replaceSpace $ toList $ unDoc doc
412− where replaceSpace BreakingSpace = Text 1 " "
413− replaceSpace x = x
411+nowrap doc = Doc $ mapWithIndex replaceSpace $ unDoc doc
412+ where replaceSpace _ BreakingSpace = Text 1 " "
413+ replaceSpace _ x = x
414414
415415-- | Returns the width of a 'Doc'.
416416offset :: Doc -> Int