diff options
author | John MacFarlane <jgm@berkeley.edu> | 2019-09-28 14:47:41 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-09-29 11:43:17 -0700 |
commit | 746c92a41a4f1df5ac97246fe69555cef5419d00 (patch) | |
tree | 4a300c58e87d1cf65cc5a55a5ef440b0bd71f1af /src/Text/Pandoc/Error.hs | |
parent | 03d4e6b9ef87d4e6ed018c93b358f8557f8f7388 (diff) | |
download | pandoc-746c92a41a4f1df5ac97246fe69555cef5419d00.tar.gz |
Raise error on unsupported extensions. Closes #4338.
+ An error is now raised if you try to specify (enable or
disable) an extension that does not affect the given
format, e.g. `docx+pipe_tables`.
+ The `--list-extensions[=FORMAT]` option now lists only
extensions that affect the given FORMAT.
+ Text.Pandoc.Error: Add constructors `PandocUnknownReaderError`,
`PandocUnknownWriterError`, `PandocUnsupportedExtensionError`.
[API change]
+ Text.Pandoc.Extensions now exports `getAllExtensions`,
which returns the extensions that affect a given format
(whether enabled by default or not). [API change]
+ Text.Pandoc.Extensions: change type of `parseFormatSpec`
from `Either ParseError (String, Extensions -> Extensions)`
to `Either ParseError (String, [Extension], [Extension])`
[API change].
+ Text.Pandoc.Readers: change type of `getReader` so it returns
a value in the PandocMonad instance rather than an Either
[API change]. Exceptions for unknown formats and unsupported
extensions are now raised by this function and need not be handled by
the calling function.
+ Text.Pandoc.Writers: change type of `getWriter` so it returns
a value in the PandocMonad instance rather than an Either
[API change]. Exceptions for unknown formats and unsupported
extensions are now raised by this function and need not be handled by
the calling function.
Diffstat (limited to 'src/Text/Pandoc/Error.hs')
-rw-r--r-- | src/Text/Pandoc/Error.hs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Error.hs b/src/Text/Pandoc/Error.hs index ae66162b3..113ab9d6e 100644 --- a/src/Text/Pandoc/Error.hs +++ b/src/Text/Pandoc/Error.hs @@ -54,6 +54,9 @@ data PandocError = PandocIOError String IOError | PandocMacroLoop String | PandocUTF8DecodingError String Int Word8 | PandocIpynbDecodingError String + | PandocUnknownReaderError String + | PandocUnknownWriterError String + | PandocUnsupportedExtensionError String String deriving (Show, Typeable, Generic) instance Exception PandocError @@ -112,6 +115,26 @@ handleError (Left e) = "The input must be a UTF-8 encoded text." PandocIpynbDecodingError w -> err 93 $ "ipynb decoding error: " ++ w + PandocUnknownReaderError r -> err 21 $ + "Unknown input format " ++ r ++ + case r of + "doc" -> "\nPandoc can convert from DOCX, but not from DOC." ++ + "\nTry using Word to save your DOC file as DOCX," ++ + " and convert that with pandoc." + "pdf" -> "\nPandoc can convert to PDF, but not from PDF." + _ -> "" + PandocUnknownWriterError w -> err 22 $ + "Unknown output format " ++ w ++ + case w of + "pdf" -> "To create a pdf using pandoc, use" ++ + " -t latex|beamer|context|ms|html5" ++ + "\nand specify an output file with " ++ + ".pdf extension (-o filename.pdf)." + "doc" -> "\nPandoc can convert to DOCX, but not from DOC." + _ -> "" + PandocUnsupportedExtensionError ext f -> err 23 $ + "The extension " ++ ext ++ " is not supported " ++ + "for " ++ f err :: Int -> String -> IO a err exitCode msg = do |