@@ -133,7 +133,7 @@ import qualified Data.ByteString as BS
133import qualified Data.ByteString.Char8 as B8
133import qualified Data.ByteString.Char8 as B8
134import Data.ByteString.Base64 (decodeLenient)
134import Data.ByteString.Base64 (decodeLenient)
135import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr)
135import Data.Sequence (ViewR(..), ViewL(..), viewl, viewr)
136−import qualified Data.Text as T (toUpper, pack, unpack)
136+import qualified Data.Text as T
137import Data.ByteString.Lazy (toChunks, fromChunks)
137import Data.ByteString.Lazy (toChunks, fromChunks)
138import qualified Data.ByteString.Lazy as BL
138import qualified Data.ByteString.Lazy as BL
139import Paths_pandoc (version)
139import Paths_pandoc (version)
@@ -279,26 +279,20 @@ escapeURI = escapeURIString (not . needsEscaping)
279 where needsEscaping c = isSpace c || c `elem`
279 where needsEscaping c = isSpace c || c `elem`
280 ['<','>','|','"','{','}','[',']','^', '`']
280 ['<','>','|','"','{','}','[',']','^', '`']
283-- | Convert tabs to spaces and filter out DOS line endings.
282-- | Convert tabs to spaces and filter out DOS line endings.
284-- Tabs will be preserved if tab stop is set to 0.
283-- Tabs will be preserved if tab stop is set to 0.
285tabFilter :: Int -- ^ Tab stop
284tabFilter :: Int -- ^ Tab stop
286− -> String -- ^ Input
285+ -> T.Text -- ^ Input
287− -> String
286+ -> T.Text
288tabFilter tabStop =
287tabFilter tabStop =
289− let go _ [] = ""
288+ T.unlines . (if tabStop == 0 then id else map go) . T.lines
290− go _ ('\n':xs) = '\n' : go tabStop xs
289+ where go s =
291− go _ ('\r':'\n':xs) = '\n' : go tabStop xs
290+ let (s1, s2) = T.break (== '\t') s
292− go _ ('\r':xs) = '\n' : go tabStop xs
291+ in if T.null s2
293− go spsToNextStop ('\t':xs) =
292+ then s1
294− if tabStop == 0
293+ else s1 <> T.replicate
295− then '\t' : go tabStop xs
294+ (tabStop - (T.length s1 `mod` tabStop)) (T.pack " ")
296− else replicate spsToNextStop ' ' ++ go tabStop xs
295+ <> go (T.drop 1 s2)
299− go spsToNextStop (x:xs) =
300− x : go (spsToNextStop - 1) xs
304-- Date/time
298-- Date/time