T.P.App.OutputSettings: Generalize some types...

so we can run this with any instance of PandocMonad and MonadIO,
not just PandocIO.
This commit is contained in:
John MacFarlane 2021-08-22 21:41:54 -07:00
parent 0efbfb33ad
commit bf860df938
2 changed files with 6 additions and 7 deletions

View file

@ -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" ||

View file

@ -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