aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-08-08 13:39:12 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-08-08 13:39:12 -0700
commit6dd689ad976f0cd873411bda7b8df07c451c2227 (patch)
tree90176c8d0dcbd5f55f80b40b6b4e1015c00e16d1 /src/Text/Pandoc
parentb6490de03b138a22e9c0af8e02b45d1de50b80de (diff)
downloadpandoc-6dd689ad976f0cd873411bda7b8df07c451c2227.tar.gz
Revert "Avoid a pointless Text -> String conversion on output."
This reverts commit 87ce1ffbd97f6cb2785f9fbf05f68d3185f50675. This change caused a problem on Windows that we didn't have before; this needs looking into. https://ci.appveyor.com/project/jgm/pandoc/build/job/fxq96log042df8dk .\pandoc.exe -s --toc ..\MANUAL.txt -o MANUAL.html pandoc.exe: MANUAL.html: commitAndReleaseBuffer: invalid argument (invalid character) Command exited with code 1
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/App.hs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index b6ab0d0ba..737e43fd9 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -34,16 +34,15 @@ import Data.Maybe (fromMaybe, isJust, isNothing)
import qualified Data.Set as Set
import Data.Text (Text)
import qualified Data.Text as T
-import qualified Data.Text.IO as TIO
import qualified Data.Text.Lazy as TL
+import qualified Data.Text.Lazy.Encoding as TE
import qualified Data.Text.Encoding.Error as TE
-import qualified Data.Text.Lazy.Encoding as TLE
+import qualified Data.Text.Encoding.Error as TSE
import Network.URI (URI (..), parseURI)
import System.Directory (doesDirectoryExist)
import System.Exit (exitSuccess)
import System.FilePath
-import System.IO (nativeNewline, stdout, hSetNewlineMode, hSetEncoding,
- NewlineMode(..), utf8)
+import System.IO (nativeNewline, stdout)
import qualified System.IO as IO (Newline (..))
import Text.Pandoc
import Text.Pandoc.App.FormatHeuristics (formatFromFilePaths)
@@ -296,7 +295,7 @@ convertWithOpts opts = do
case res of
Right pdf -> writeFnBinary outputFile pdf
Left err' -> throwError $ PandocPDFError $
- TL.unpack (TLE.decodeUtf8With TE.lenientDecode err')
+ TL.unpack (TE.decodeUtf8With TE.lenientDecode err')
Nothing -> do
let addNl = if standalone
@@ -366,7 +365,7 @@ readSource src = case parseURI src of
else BS.readFile fp
E.catch (return $! UTF8.toText bs)
(\e -> case e of
- TE.DecodeError _ (Just w) -> do
+ TSE.DecodeError _ (Just w) -> do
case BS.elemIndex w bs of
Just offset -> E.throwIO $
PandocUTF8DecodingError fp offset w
@@ -385,11 +384,6 @@ writeFnBinary "-" = liftIO . BL.putStr
writeFnBinary f = liftIO . BL.writeFile (UTF8.encodePath f)
writerFn :: MonadIO m => IO.Newline -> FilePath -> Text -> m ()
-writerFn eol "-" t = liftIO $ do
- hSetNewlineMode stdout (NewlineMode eol eol)
- hSetEncoding stdout utf8
- TIO.putStr t
-writerFn eol f t = liftIO $ do
- hSetNewlineMode stdout (NewlineMode eol eol)
- hSetEncoding stdout utf8
- TIO.writeFile f t
+-- TODO this implementation isn't maximally efficient:
+writerFn eol "-" = liftIO . UTF8.putStrWith eol . T.unpack
+writerFn eol f = liftIO . UTF8.writeFileWith eol f . T.unpack