aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pandoc.hs23
-rw-r--r--src/Text/Pandoc.hs35
2 files changed, 29 insertions, 29 deletions
diff --git a/pandoc.hs b/pandoc.hs
index d39ed3a59..93e1d4a76 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -47,7 +47,7 @@ import System.Exit ( exitWith, ExitCode (..) )
import System.FilePath
import System.Console.GetOpt
import Data.Char ( toLower )
-import Data.List ( intercalate, isPrefixOf, sort )
+import Data.List ( intercalate, isPrefixOf, isSuffixOf, sort )
import System.Directory ( getAppUserDataDirectory, findExecutable,
doesFileExist )
import System.IO ( stdout, stderr )
@@ -1021,15 +1021,18 @@ main = do
let laTeXOutput = "latex" `isPrefixOf` writerName' ||
"beamer" `isPrefixOf` writerName'
- writer <- case getWriter writerName' of
- Left e -> err 9 $
- if writerName' == "pdf"
- then e ++ "\nTo create a pdf with pandoc, use the " ++
- "latex or beamer writer and specify\n" ++
- "an output file with .pdf extension " ++
- "(pandoc -t latex -o filename.pdf)."
- else e
- Right w -> return w
+ writer <- if ".lua" `isSuffixOf` writerName'
+ -- note: use non-lowercased version writerName
+ then return $ IOStringWriter $ writeCustom writerName
+ else case getWriter writerName' of
+ Left e -> err 9 $
+ if writerName' == "pdf"
+ then e ++ "\nTo create a pdf with pandoc, use " ++
+ "the latex or beamer writer and specify\n" ++
+ "an output file with .pdf extension " ++
+ "(pandoc -t latex -o filename.pdf)."
+ else e
+ Right w -> return w
reader <- case getReader readerName' of
Right r -> return r
diff --git a/src/Text/Pandoc.hs b/src/Text/Pandoc.hs
index 66b0e49c0..a37c98814 100644
--- a/src/Text/Pandoc.hs
+++ b/src/Text/Pandoc.hs
@@ -152,7 +152,7 @@ import Text.Pandoc.Options
import Text.Pandoc.Shared (safeRead, warn)
import Data.Aeson
import qualified Data.ByteString.Lazy as BL
-import Data.List (intercalate, isSuffixOf)
+import Data.List (intercalate)
import Data.Version (showVersion)
import Data.Set (Set)
import qualified Data.Set as Set
@@ -292,24 +292,21 @@ getReader s =
-- | Retrieve writer based on formatSpec (format+extensions).
getWriter :: String -> Either String Writer
-getWriter s =
- case parseFormatSpec s of
- Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]
- Right (writerName, setExts) ->
- case lookup writerName writers of
- Nothing
- | ".lua" `isSuffixOf` s ->
- Right $ IOStringWriter $ writeCustom s
- | otherwise -> Left $ "Unknown writer: " ++ writerName
- Just (PureStringWriter r) -> Right $ PureStringWriter $
- \o -> r o{ writerExtensions = setExts $
- getDefaultExtensions writerName }
- Just (IOStringWriter r) -> Right $ IOStringWriter $
- \o -> r o{ writerExtensions = setExts $
- getDefaultExtensions writerName }
- Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $
- \o -> r o{ writerExtensions = setExts $
- getDefaultExtensions writerName }
+getWriter s
+ = case parseFormatSpec s of
+ Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]
+ Right (writerName, setExts) ->
+ case lookup writerName writers of
+ Nothing -> Left $ "Unknown writer: " ++ writerName
+ Just (PureStringWriter r) -> Right $ PureStringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
+ Just (IOStringWriter r) -> Right $ IOStringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
+ Just (IOByteStringWriter r) -> Right $ IOByteStringWriter $
+ \o -> r o{ writerExtensions = setExts $
+ getDefaultExtensions writerName }
{-# DEPRECATED toJsonFilter "Use 'toJSONFilter' from 'Text.Pandoc.JSON' instead" #-}
-- | Deprecated. Use @toJSONFilter@ from @Text.Pandoc.JSON@ instead.