diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-08 08:32:32 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-08 08:32:32 -0800 |
commit | 142c29d90827f81bcccad35ed39f3669298b8961 (patch) | |
tree | b5fabadba4e18cc6995766cafbcea09aa1960bea | |
parent | 11e1e2b92294fb476c8433c7f24402ecdf0914cf (diff) | |
download | pandoc-142c29d90827f81bcccad35ed39f3669298b8961.tar.gz |
More efficient implementation of nowrap in Pretty.
-rw-r--r-- | src/Text/Pandoc/Pretty.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Pretty.hs b/src/Text/Pandoc/Pretty.hs index 8c752c1be..bf78b2594 100644 --- a/src/Text/Pandoc/Pretty.hs +++ b/src/Text/Pandoc/Pretty.hs @@ -72,7 +72,7 @@ module Text.Pandoc.Pretty ( ) where -import Data.Sequence (Seq, fromList, (<|), singleton) +import Data.Sequence (Seq, fromList, (<|), singleton, mapWithIndex) import Data.Foldable (toList) import Data.List (intercalate) import Data.Monoid @@ -408,9 +408,9 @@ beforeNonBlank d = Doc $ singleton (BeforeNonBlank d) -- | Makes a 'Doc' non-reflowable. nowrap :: Doc -> Doc -nowrap doc = Doc $ fromList $ map replaceSpace $ toList $ unDoc doc - where replaceSpace BreakingSpace = Text 1 " " - replaceSpace x = x +nowrap doc = Doc $ mapWithIndex replaceSpace $ unDoc doc + where replaceSpace _ BreakingSpace = Text 1 " " + replaceSpace _ x = x -- | Returns the width of a 'Doc'. offset :: Doc -> Int |