diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 76828e9d8..6d2208785 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -366,10 +366,11 @@ configureCommonState datadir opts = do -- only affect the Markdown reader. readAbbreviations :: PandocMonad m => Maybe FilePath -> m (Set.Set Text) readAbbreviations mbfilepath = - Set.fromList . filter (not . T.null) . T.lines . UTF8.toText <$> - case mbfilepath of + (case mbfilepath of Nothing -> readDataFile "abbreviations" - Just f -> readFileStrict f + Just f -> readFileStrict f) + >>= fmap (Set.fromList . filter (not . T.null) . T.lines) . + toTextM (fromMaybe mempty mbfilepath) createPngFallbacks :: (PandocMonad m, MonadIO m) => Int -> m () createPngFallbacks dpi = do diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index af5c0ddbc..7f5d844e4 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -47,7 +47,7 @@ import Text.Pandoc.Scripting (ScriptingEngine (engineLoadCustom), import qualified Text.Pandoc.UTF8 as UTF8 readUtf8File :: PandocMonad m => FilePath -> m T.Text -readUtf8File = fmap UTF8.toText . readFileStrict +readUtf8File fp = readFileStrict fp >>= toTextM fp -- | Settings specifying how document output should be produced. data OutputSettings m = OutputSettings @@ -174,7 +174,7 @@ optToOutputSettings scriptingEngine opts = do (ListVal $ v : map toVal vs) ctxMap Nothing -> M.insert k (toVal vs) ctxMap - let getTextContents fp = UTF8.toText . fst <$> fetchItem (T.pack fp) + let getTextContents fp = (fst <$> fetchItem (T.pack fp)) >>= toTextM fp let setFilesVariableM k fps ctx = do xs <- mapM getTextContents fps @@ -209,8 +209,9 @@ optToOutputSettings scriptingEngine opts = do >>= (\vars -> if format == "dzslides" then do - dztempl <- UTF8.toText <$> readDataFile - ("dzslides" "template.html") + dztempl <- + let fp = "dzslides" "template.html" + in readDataFile fp >>= toTextM fp let dzline = "