@@ -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