aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/App.hs6
-rw-r--r--src/Text/Pandoc/App/OutputSettings.hs7
-rw-r--r--src/Text/Pandoc/Readers.hs9
-rw-r--r--src/Text/Pandoc/Writers.hs9
4 files changed, 15 insertions, 16 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 0306b3b22..49fe34172 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -149,7 +149,7 @@ convertWithOpts' scriptingEngine istty datadir opts = do
(map (T.pack . takeExtension) sources) "markdown"
return "markdown"
- Format.FlavoredFormat readerNameBase _extsDiff <-
+ flvrd@(Format.FlavoredFormat readerNameBase _extsDiff) <-
Format.parseFlavoredFormat readerName
let makeSandboxed pureReader =
let files = maybe id (:) (optReferenceDoc opts) .
@@ -174,10 +174,10 @@ convertWithOpts' scriptingEngine istty datadir opts = do
, mempty
)
else if optSandbox opts
- then case runPure (getReader readerName) of
+ then case runPure (getReader flvrd) of
Left e -> throwError e
Right (r, rexts) -> return (makeSandboxed r, rexts)
- else getReader readerName
+ else getReader flvrd
outputSettings <- optToOutputSettings scriptingEngine opts
let format = outputFormat outputSettings
diff --git a/src/Text/Pandoc/App/OutputSettings.hs b/src/Text/Pandoc/App/OutputSettings.hs
index 5851d433c..20321f52a 100644
--- a/src/Text/Pandoc/App/OutputSettings.hs
+++ b/src/Text/Pandoc/App/OutputSettings.hs
@@ -102,17 +102,18 @@ optToOutputSettings scriptingEngine opts = do
ByteStringWriter w ->
ByteStringWriter $ \o d -> sandbox files (w o d)
- Format.FlavoredFormat format _extsDiff <- Format.parseFlavoredFormat writerName
+ flvrd@(Format.FlavoredFormat format _extsDiff) <-
+ Format.parseFlavoredFormat writerName
(writer, writerExts) <-
if "lua" `T.isSuffixOf` format
then do
(, mempty) <$> engineWriteCustom scriptingEngine (T.unpack format)
else do
if optSandbox opts
- then case runPure (getWriter writerName) of
+ then case runPure (getWriter flvrd) of
Right (w, wexts) -> return (makeSandboxed w, wexts)
Left e -> throwError e
- else getWriter writerName
+ else getWriter flvrd
let standalone = optStandalone opts || not (isTextFormat format) || pdfOutput
diff --git a/src/Text/Pandoc/Readers.hs b/src/Text/Pandoc/Readers.hs
index ab660c5b2..61f7326ac 100644
--- a/src/Text/Pandoc/Readers.hs
+++ b/src/Text/Pandoc/Readers.hs
@@ -163,14 +163,13 @@ readers = [("native" , TextReader readNative)
]
-- | Retrieve reader, extensions based on format spec (format+extensions).
-getReader :: PandocMonad m => Text -> m (Reader m, Extensions)
-getReader s = do
- spec <- Format.parseFlavoredFormat s
- let readerName = Format.formatName spec
+getReader :: PandocMonad m => Format.FlavoredFormat -> m (Reader m, Extensions)
+getReader flvrd = do
+ let readerName = Format.formatName flvrd
case lookup readerName readers of
Nothing -> throwError $ PandocUnknownReaderError readerName
Just r -> (r,) <$>
- Format.applyExtensionsDiff (Format.getExtensionsConfig readerName) spec
+ Format.applyExtensionsDiff (Format.getExtensionsConfig readerName) flvrd
-- | Read pandoc document from JSON format.
readJSON :: (PandocMonad m, ToSources a)
diff --git a/src/Text/Pandoc/Writers.hs b/src/Text/Pandoc/Writers.hs
index fc2b28e8f..92881e44c 100644
--- a/src/Text/Pandoc/Writers.hs
+++ b/src/Text/Pandoc/Writers.hs
@@ -192,14 +192,13 @@ writers = [
]
-- | Retrieve writer, extensions based on formatSpec (format+extensions).
-getWriter :: PandocMonad m => Text -> m (Writer m, Extensions)
-getWriter s = do
- spec <- Format.parseFlavoredFormat s
- let writerName = Format.formatName spec
+getWriter :: PandocMonad m => Format.FlavoredFormat -> m (Writer m, Extensions)
+getWriter flvrd = do
+ let writerName = Format.formatName flvrd
case lookup writerName writers of
Nothing -> throwError $ PandocUnknownWriterError writerName
Just w -> (w,) <$>
- Format.applyExtensionsDiff (Format.getExtensionsConfig writerName) spec
+ Format.applyExtensionsDiff (Format.getExtensionsConfig writerName) flvrd
writeJSON :: PandocMonad m => WriterOptions -> Pandoc -> m Text
writeJSON _ = return . UTF8.toText . BL.toStrict . encode