diff options
author | Mauro Bieg <mb21@users.noreply.github.com> | 2019-09-09 01:03:13 +0200 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2019-09-08 16:03:13 -0700 |
commit | d96a5629bc7a8f4c711ffdb7299dfe8a9a041216 (patch) | |
tree | eed3c3a4f338250b8f81ce785136eb781994bc28 /src/Text/Pandoc | |
parent | f0577fe3609e81f653570e3e8e164be1d3ddbcef (diff) | |
download | pandoc-d96a5629bc7a8f4c711ffdb7299dfe8a9a041216.tar.gz |
Emit warning on `-f latex -o out.pdf` (#5736)
add UnusualConversion to LogMessage [API change]
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/App.hs | 8 | ||||
-rw-r--r-- | src/Text/Pandoc/Logging.hs | 6 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs index 741f2d37b..49b20f9dc 100644 --- a/src/Text/Pandoc/App.hs +++ b/src/Text/Pandoc/App.hs @@ -147,6 +147,14 @@ convertWithOpts opts = do let pdfOutput = map toLower (takeExtension outputFile) == ".pdf" + when (pdfOutput && readerName == "latex") $ + case (optInputFiles opts) of + (inputFile:_) -> report $ UnusualConversion $ + "to convert a .tex file to PDF, you get better results by using pdflatex " + <> "(or lualatex or xelatex) directly, try `pdflatex " <> inputFile + <> "` instead of `pandoc " <> inputFile <> " -o " <> outputFile <> "`." + _ -> return () + (reader, readerExts) <- case getReader readerName of Right (r, es) -> return (r :: Reader PandocIO, es) diff --git a/src/Text/Pandoc/Logging.hs b/src/Text/Pandoc/Logging.hs index 4107dc121..4e2d6f1b5 100644 --- a/src/Text/Pandoc/Logging.hs +++ b/src/Text/Pandoc/Logging.hs @@ -86,6 +86,7 @@ data LogMessage = | Deprecated String String | NoTranslation String | CouldNotLoadTranslations String String + | UnusualConversion String | UnexpectedXmlElement String String | UnknownOrgExportOption String | UnknownExtensions [String] String @@ -203,6 +204,8 @@ instance ToJSON LogMessage where CouldNotLoadTranslations lang msg -> ["lang" .= Text.pack lang, "message" .= Text.pack msg] + UnusualConversion msg -> + ["message" .= Text.pack msg] UnexpectedXmlElement element parent -> ["element" .= Text.pack element, "parent" .= Text.pack parent] @@ -310,6 +313,8 @@ showLogMessage msg = CouldNotLoadTranslations lang m -> "Could not load translations for " ++ lang ++ if null m then "" else '\n' : m + UnusualConversion m -> + "Unusual conversion: " ++ m UnexpectedXmlElement element parent -> "Unexpected XML element " ++ element ++ " in " ++ parent UnknownOrgExportOption option -> @@ -357,6 +362,7 @@ messageVerbosity msg = Deprecated{} -> WARNING NoTranslation{} -> WARNING CouldNotLoadTranslations{} -> WARNING + UnusualConversion {} -> WARNING UnexpectedXmlElement {} -> WARNING UnknownOrgExportOption {} -> WARNING UnknownExtensions{} -> WARNING |