From bf860df938782fc1862ce95d12b47c40e564373b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 22 Aug 2021 21:41:54 -0700 Subject: T.P.App.OutputSettings: Generalize some types... so we can run this with any instance of PandocMonad and MonadIO, not just PandocIO. --- src/Text/Pandoc/App.hs | 2 +- src/Text/Pandoc/App/OutputSettings.hs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 5696156ad..dd58b1b39 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -133,7 +133,7 @@ convertWithOpts opts = do <> "` instead of `pandoc " <> inputFile <> " -o " <> outputFile <> "`." _ -> return () - (reader :: Reader PandocIO, readerExts) <- getReader readerName + (reader, readerExts) <- getReader readerName let convertTabs = tabFilter (if optPreserveTabs opts || readerNameBase == "t2t" || diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs index 3864ab188..3f83f4b21 100644 --- a/src/Text/Pandoc/App/OutputSettings.hs +++ b/src/Text/Pandoc/App/OutputSettings.hs @@ -45,16 +45,16 @@ readUtf8File :: PandocMonad m => FilePath -> m T.Text readUtf8File = fmap UTF8.toText . readFileStrict -- | Settings specifying how document output should be produced. -data OutputSettings = OutputSettings +data OutputSettings m = OutputSettings { outputFormat :: T.Text - , outputWriter :: Writer PandocIO + , outputWriter :: Writer m , outputWriterName :: T.Text , outputWriterOptions :: WriterOptions , outputPdfProgram :: Maybe String } -- | Get output settings from command line options. -optToOutputSettings :: Opt -> PandocIO OutputSettings +optToOutputSettings :: (PandocMonad m, MonadIO m) => Opt -> m (OutputSettings m) optToOutputSettings opts = do let outputFile = fromMaybe "-" (optOutputFile opts) @@ -90,11 +90,10 @@ optToOutputSettings opts = do then writerName else T.toLower $ baseWriterName writerName - (writer :: Writer PandocIO, writerExts) <- + (writer, writerExts) <- if ".lua" `T.isSuffixOf` format then return (TextWriter - (\o d -> writeCustom (T.unpack writerName) o d) - :: Writer PandocIO, mempty) + (\o d -> writeCustom (T.unpack writerName) o d), mempty) else getWriter (T.toLower writerName) let standalone = optStandalone opts || not (isTextFormat format) || pdfOutput -- cgit v1.2.3