git.iko.soy/typeable/pandoc
on master help sign in
Removed `--strict`, added extensions to writer/reader names.
0cb7362John MacFarlane
README+15−22
@@ -26,8 +26,8 @@ tables, flexible ordered lists, definition lists, delimited code blocks,
26superscript, subscript, strikeout, title blocks, automatic tables of
26superscript, subscript, strikeout, title blocks, automatic tables of
27contents, embedded LaTeX math, citations, and markdown inside HTML block
27contents, embedded LaTeX math, citations, and markdown inside HTML block
28elements. (These enhancements, described below under
28elements. (These enhancements, described below under
29−[Pandoc's markdown](#pandocs-markdown), can be disabled using the `--strict`
29+[Pandoc's markdown](#pandocs-markdown), can be disabled using the `strict`
30−option.)
30+input or output format.)
31
31
32In contrast to most existing tools for converting markdown to HTML, which
32In contrast to most existing tools for converting markdown to HTML, which
33use regex substitutions, Pandoc has a modular design: it consists of a
33use regex substitutions, Pandoc has a modular design: it consists of a
@@ -117,10 +117,11 @@ and `xunicode` (if `xelatex` is used).
117
117
118A user who wants a drop-in replacement for `Markdown.pl` may create
118A user who wants a drop-in replacement for `Markdown.pl` may create
119a symbolic link to the `pandoc` executable called `hsmarkdown`. When
119a symbolic link to the `pandoc` executable called `hsmarkdown`. When
120−invoked under the name `hsmarkdown`, `pandoc` will behave as if the
120+invoked under the name `hsmarkdown`, `pandoc` will behave as if
121+invoked with `-f strict --email-obfuscation=references`,
121−`--strict` flag had been selected, and no command-line options will be
122+and all command-line options will be treated as regular arguments.
122−recognized. However, this approach does not work under Cygwin, due to
123+However, this approach does not work under Cygwin, due to problems with
123−problems with its simulation of symbolic links.
124+its simulation of symbolic links.
124
125
125[Cygwin]: http://www.cygwin.com/
126[Cygwin]: http://www.cygwin.com/
126[`iconv`]: http://www.gnu.org/software/libiconv/
127[`iconv`]: http://www.gnu.org/software/libiconv/
@@ -192,12 +193,6 @@ General options
192Reader options
193Reader options
193--------------
194--------------
194
195
195−`--strict`
196−: Use strict markdown syntax, with no pandoc extensions or variants.
197− When the input format is HTML, this means that constructs that have no
198− equivalents in standard markdown (e.g. definition lists or strikeout
199− text) will be parsed as raw HTML.
200−
201`-R`, `--parse-raw`
196`-R`, `--parse-raw`
202: Parse untranslatable HTML codes and LaTeX environments as raw HTML
197: Parse untranslatable HTML codes and LaTeX environments as raw HTML
203 or LaTeX, instead of ignoring them. Affects only HTML and LaTeX
198 or LaTeX, instead of ignoring them. Affects only HTML and LaTeX
@@ -403,8 +398,6 @@ Options affecting specific writers
403 *none* leaves `mailto:` links as they are. *javascript* obfuscates
398 *none* leaves `mailto:` links as they are. *javascript* obfuscates
404 them using javascript. *references* obfuscates them by printing their
399 them using javascript. *references* obfuscates them by printing their
405 letters as decimal or hexadecimal character references.
400 letters as decimal or hexadecimal character references.
406− If `--strict` is specified, *references* is used regardless of the
407− presence of this option.
408
401
409`--id-prefix`=*STRING*
402`--id-prefix`=*STRING*
410: Specify a prefix to be added to all automatically generated identifiers
403: Specify a prefix to be added to all automatically generated identifiers
@@ -764,8 +757,8 @@ Pandoc's markdown
764Pandoc understands an extended and slightly revised version of
757Pandoc understands an extended and slightly revised version of
765John Gruber's [markdown] syntax. This document explains the syntax,
758John Gruber's [markdown] syntax. This document explains the syntax,
766noting differences from standard markdown. Except where noted, these
759noting differences from standard markdown. Except where noted, these
767−differences can be suppressed by specifying the `--strict` command-line
760+differences can be suppressed by using the `strict` format instead
768−option.
761+of `markdown`.
769
762
770Philosophy
763Philosophy
771----------
764----------
@@ -934,8 +927,8 @@ Standard markdown syntax does not require a blank line before a block
934quote. Pandoc does require this (except, of course, at the beginning of the
927quote. Pandoc does require this (except, of course, at the beginning of the
935document). The reason for the requirement is that it is all too easy for a
928document). The reason for the requirement is that it is all too easy for a
936`>` to end up at the beginning of a line by accident (perhaps through line
929`>` to end up at the beginning of a line by accident (perhaps through line
937−wrapping). So, unless `--strict` is used, the following does not produce
930+wrapping). So, unless the `strict` format is used, the following does
938−a nested block quote in pandoc:
931+not produce a nested block quote in pandoc:
939
932
940 > This is a block quote.
933 > This is a block quote.
941 >> Nested.
934 >> Nested.
@@ -1291,7 +1284,7 @@ around "Third". Pandoc follows a simple rule: if the text is followed by
1291a blank line, it is treated as a paragraph. Since "Second" is followed
1284a blank line, it is treated as a paragraph. Since "Second" is followed
1292by a list, and not a blank line, it isn't treated as a paragraph. The
1285by a list, and not a blank line, it isn't treated as a paragraph. The
1293fact that the list is followed by a blank line is irrelevant. (Note:
1286fact that the list is followed by a blank line is irrelevant. (Note:
1294−Pandoc works this way even when the `--strict` option is specified. This
1287+Pandoc works this way even when the `strict` format is specified. This
1295behavior is consistent with the official markdown syntax description,
1288behavior is consistent with the official markdown syntax description,
1296even though it is different from that of `Markdown.pl`.)
1289even though it is different from that of `Markdown.pl`.)
1297
1290
@@ -1612,8 +1605,8 @@ which allows only the following characters to be backslash-escaped:
1612
1605
1613 \`*_{}[]()>#+-.!
1606 \`*_{}[]()>#+-.!
1614
1607
1615−(However, if the `--strict` option is supplied, the standard
1608+(However, if the `strict` format is used, the standard markdown rule
1616−markdown rule will be used.)
1609+will be used.)
1617
1610
1618A backslash-escaped space is parsed as a nonbreaking space. It will
1611A backslash-escaped space is parsed as a nonbreaking space. It will
1619appear in TeX output as `~` and in HTML and XML as `\ ` or
1612appear in TeX output as `~` and in HTML and XML as `\ ` or
@@ -1847,7 +1840,7 @@ with blank lines, and start and end at the left margin. Within
1847these blocks, everything is interpreted as HTML, not markdown;
1840these blocks, everything is interpreted as HTML, not markdown;
1848so (for example), `*` does not signify emphasis.
1841so (for example), `*` does not signify emphasis.
1849
1842
1850−Pandoc behaves this way when `--strict` is specified; but by default,
1843+Pandoc behaves this way when the `strict` format is used; but by default,
1851pandoc interprets material between HTML block tags as markdown.
1844pandoc interprets material between HTML block tags as markdown.
1852Thus, for example, Pandoc will turn
1845Thus, for example, Pandoc will turn
1853
1846
src/Text/Pandoc.hs+14−5
@@ -139,11 +139,13 @@ import Text.Pandoc.Templates
139import Text.Pandoc.Options
139import Text.Pandoc.Options
140import Text.Pandoc.Shared (safeRead)
140import Text.Pandoc.Shared (safeRead)
141import Data.ByteString.Lazy (ByteString)
141import Data.ByteString.Lazy (ByteString)
142+import Data.List (intercalate)
142import Data.Version (showVersion)
143import Data.Version (showVersion)
143import Text.JSON.Generic
144import Text.JSON.Generic
144import Data.Set (Set)
145import Data.Set (Set)
145import qualified Data.Set as Set
146import qualified Data.Set as Set
146import Text.Parsec
147import Text.Parsec
148+import Text.Parsec.Error
147import Paths_pandoc (version)
149import Paths_pandoc (version)
148
150
149-- | Version number of pandoc library.
151-- | Version number of pandoc library.
@@ -160,10 +162,12 @@ parseFormatSpec = parse formatSpec ""
160 formatName = many1 $ noneOf "-+"
162 formatName = many1 $ noneOf "-+"
161 extMod = do
163 extMod = do
162 polarity <- oneOf "-+"
164 polarity <- oneOf "-+"
163− name <- many1 $ noneOf "-+"
165+ name <- many $ noneOf "-+"
164− ext <- case safeRead name of
166+ ext <- case safeRead ("Ext_" ++ name) of
165 Just n -> return n
167 Just n -> return n
168+ Nothing
169+ | name == "lhs" -> return Ext_literate_haskell
166− Nothing -> unexpected $ "Unknown extension: " ++ name
170+ | otherwise -> fail $ "Unknown extension: " ++ name
167 return $ case polarity of
171 return $ case polarity of
168 '-' -> Set.delete ext
172 '-' -> Set.delete ext
169 _ -> Set.insert ext
173 _ -> Set.insert ext
@@ -172,6 +176,8 @@ parseFormatSpec = parse formatSpec ""
172readers :: [(String, ReaderOptions -> String -> Pandoc)]
176readers :: [(String, ReaderOptions -> String -> Pandoc)]
173readers = [("native" , \_ -> readNative)
177readers = [("native" , \_ -> readNative)
174 ,("json" , \_ -> decodeJSON)
178 ,("json" , \_ -> decodeJSON)
179+ ,("strict" , \o -> readMarkdown
180+ o{ readerExtensions = strictExtensions } )
175 ,("markdown" , readMarkdown)
181 ,("markdown" , readMarkdown)
176 ,("rst" , readRST)
182 ,("rst" , readRST)
177 ,("docbook" , readDocBook)
183 ,("docbook" , readDocBook)
@@ -215,6 +221,8 @@ writers = [
215 ,("texinfo" , PureStringWriter writeTexinfo)
221 ,("texinfo" , PureStringWriter writeTexinfo)
216 ,("man" , PureStringWriter writeMan)
222 ,("man" , PureStringWriter writeMan)
217 ,("markdown" , PureStringWriter writeMarkdown)
223 ,("markdown" , PureStringWriter writeMarkdown)
224+ ,("strict" , PureStringWriter $ \o ->
225+ writeMarkdown o{ writerExtensions = strictExtensions } )
218 ,("plain" , PureStringWriter writePlain)
226 ,("plain" , PureStringWriter writePlain)
219 ,("rst" , PureStringWriter writeRST)
227 ,("rst" , PureStringWriter writeRST)
220 ,("mediawiki" , PureStringWriter writeMediaWiki)
228 ,("mediawiki" , PureStringWriter writeMediaWiki)
@@ -224,10 +232,11 @@ writers = [
224 ,("asciidoc" , PureStringWriter writeAsciiDoc)
232 ,("asciidoc" , PureStringWriter writeAsciiDoc)
225 ]
233 ]
226
234
235+-- | Retrieve reader based on formatSpec (format+extensions).
227getReader :: String -> Either String (ReaderOptions -> String -> Pandoc)
236getReader :: String -> Either String (ReaderOptions -> String -> Pandoc)
228getReader s =
237getReader s =
229 case parseFormatSpec s of
238 case parseFormatSpec s of
230− Left e -> Left $ show e
239+ Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]
231 Right (readerName, setExts) ->
240 Right (readerName, setExts) ->
232 case lookup readerName readers of
241 case lookup readerName readers of
233 Nothing -> Left $ "Unknown reader: " ++ readerName
242 Nothing -> Left $ "Unknown reader: " ++ readerName
@@ -239,7 +248,7 @@ getReader s =
239getWriter :: String -> Either String Writer
248getWriter :: String -> Either String Writer
240getWriter s =
249getWriter s =
241 case parseFormatSpec s of
250 case parseFormatSpec s of
242− Left e -> Left $ show e
251+ Left e -> Left $ intercalate "\n" $ [m | Message m <- errorMessages e]
243 Right (writerName, setExts) ->
252 Right (writerName, setExts) ->
244 case lookup writerName writers of
253 case lookup writerName writers of
245 Nothing -> Left $ "Unknown writer: " ++ writerName
254 Nothing -> Left $ "Unknown writer: " ++ writerName
src/Text/Pandoc/Shared.hs+3−2
@@ -498,5 +498,6 @@ warn msg = do
498
498
499safeRead :: (Monad m, Read a) => String -> m a
499safeRead :: (Monad m, Read a) => String -> m a
500safeRead s = case reads s of
500safeRead s = case reads s of
501+ (d,x):_
501− (d,[]):_ -> return d
502+ | all isSpace x -> return d
502− _ -> fail $ "Could not read `" ++ s ++ "'"
503+ _ -> fail $ "Could not read `" ++ s ++ "'"
src/Text/Pandoc/Templates.hs+9−8
@@ -86,15 +86,16 @@ import qualified Control.Exception.Extensible as E (try, IOException)
86getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first
86getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first
87 -> String -- ^ Name of writer
87 -> String -- ^ Name of writer
88 -> IO (Either E.IOException String)
88 -> IO (Either E.IOException String)
89−getDefaultTemplate _ "native" = return $ Right ""
90−getDefaultTemplate _ "json" = return $ Right ""
91−getDefaultTemplate _ "docx" = return $ Right ""
92−getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument"
93−getDefaultTemplate user "epub" = getDefaultTemplate user "html"
94getDefaultTemplate user writer = do
89getDefaultTemplate user writer = do
95− let format = takeWhile (/='+') writer -- strip off "+lhs" if present
90+ let format = takeWhile (`notElem` "+-") writer -- strip off extensions
91+ case format of
92+ "native" -> return $ Right ""
93+ "json" -> return $ Right ""
94+ "docx" -> return $ Right ""
95+ "odt" -> getDefaultTemplate user "opendocument"
96+ "epub" -> return $ Right ""
96− let fname = "templates" </> "default" <.> format
97+ _ -> let fname = "templates" </> "default" <.> format
97− E.try $ readDataFile user fname
98+ in E.try $ readDataFile user fname
98
99
99data TemplateState = TemplateState Int [(String,String)]
100data TemplateState = TemplateState Int [(String,String)]
100
101
src/pandoc.hs+32−41
@@ -44,7 +44,7 @@ import System.Exit ( exitWith, ExitCode (..) )
44import System.FilePath
44import System.FilePath
45import System.Console.GetOpt
45import System.Console.GetOpt
46import Data.Char ( toLower )
46import Data.Char ( toLower )
47−import Data.List ( intercalate, isSuffixOf, isPrefixOf )
47+import Data.List ( intercalate, isPrefixOf )
48import System.Directory ( getAppUserDataDirectory, doesFileExist, findExecutable )
48import System.Directory ( getAppUserDataDirectory, doesFileExist, findExecutable )
49import System.IO ( stdout )
49import System.IO ( stdout )
50import System.IO.Error ( isDoesNotExistError )
50import System.IO.Error ( isDoesNotExistError )
@@ -58,7 +58,6 @@ import Network.HTTP (simpleHTTP, mkRequest, getResponseBody, RequestMethod(..))
58import Network.URI (parseURI, isURI, URI(..))
58import Network.URI (parseURI, isURI, URI(..))
59import qualified Data.ByteString.Lazy as B
59import qualified Data.ByteString.Lazy as B
60import Data.ByteString.Lazy.UTF8 (toString)
60import Data.ByteString.Lazy.UTF8 (toString)
61−import qualified Data.Set as Set
62import Text.CSL.Reference (Reference(..))
61import Text.CSL.Reference (Reference(..))
63#if MIN_VERSION_base(4,4,0)
62#if MIN_VERSION_base(4,4,0)
64#else
63#else
@@ -99,8 +98,8 @@ wrapWords indent c = wrap' (c - indent) (c - indent)
99 then ",\n" ++ replicate indent ' ' ++ x ++ wrap' cols (cols - length x) xs
98 then ",\n" ++ replicate indent ' ' ++ x ++ wrap' cols (cols - length x) xs
100 else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs
99 else ", " ++ x ++ wrap' cols (remaining - (length x + 2)) xs
101
100
102−nonTextFormats :: [String]
101+isTextFormat :: String -> Bool
103−nonTextFormats = ["odt","docx","epub"]
102+isTextFormat s = takeWhile (`notElem` "+-") s `notElem` ["odt","docx","epub"]
104
103
105-- | Data structure for command line options.
104-- | Data structure for command line options.
106data Opt = Opt
105data Opt = Opt
@@ -133,7 +132,6 @@ data Opt = Opt
133 , optEPUBFonts :: [FilePath] -- ^ EPUB fonts to embed
132 , optEPUBFonts :: [FilePath] -- ^ EPUB fonts to embed
134 , optDumpArgs :: Bool -- ^ Output command-line arguments
133 , optDumpArgs :: Bool -- ^ Output command-line arguments
135 , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
134 , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
136− , optStrict :: Bool -- ^ Use strict markdown syntax
137 , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
135 , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
138 , optWrapText :: Bool -- ^ Wrap text
136 , optWrapText :: Bool -- ^ Wrap text
139 , optColumns :: Int -- ^ Line length in characters
137 , optColumns :: Int -- ^ Line length in characters
@@ -186,7 +184,6 @@ defaultOpts = Opt
186 , optEPUBFonts = []
184 , optEPUBFonts = []
187 , optDumpArgs = False
185 , optDumpArgs = False
188 , optIgnoreArgs = False
186 , optIgnoreArgs = False
189− , optStrict = False
190 , optReferenceLinks = False
187 , optReferenceLinks = False
191 , optWrapText = True
188 , optWrapText = True
192 , optColumns = 72
189 , optColumns = 72
@@ -237,7 +234,10 @@ options =
237
234
238 , Option "" ["strict"]
235 , Option "" ["strict"]
239 (NoArg
236 (NoArg
237+ (\opt -> do
238+ err 59 $ "The --strict option has been removed.\n" ++
239+ "Use `strict' input or output format instead."
240− (\opt -> return opt { optStrict = True } ))
240+ return opt ))
241 "" -- "Disable markdown syntax extensions"
241 "" -- "Disable markdown syntax extensions"
242
242
243 , Option "R" ["parse-raw"]
243 , Option "R" ["parse-raw"]
@@ -702,7 +702,7 @@ usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
702usageMessage programName = usageInfo
702usageMessage programName = usageInfo
703 (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
703 (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
704 (wrapWords 16 78 $ readers'names) ++ "\nOutput formats: " ++
704 (wrapWords 16 78 $ readers'names) ++ "\nOutput formats: " ++
705− (wrapWords 16 78 $ writers'names ++ nonTextFormats) ++ "\nOptions:")
705+ (wrapWords 16 78 $ writers'names) ++ "\nOptions:")
706 where
706 where
707 writers'names = map fst writers
707 writers'names = map fst writers
708 readers'names = map fst readers
708 readers'names = map fst readers
@@ -782,9 +782,10 @@ main = do
782 ["Try " ++ prg ++ " --help for more information."]
782 ["Try " ++ prg ++ " --help for more information."]
783
783
784 let defaultOpts' = if compatMode
784 let defaultOpts' = if compatMode
785− then defaultOpts { optReader = "markdown"
785+ then defaultOpts { optReader = "strict"
786 , optWriter = "html"
786 , optWriter = "html"
787− , optStrict = True }
787+ , optEmailObfuscation =
788+ ReferenceObfuscation }
788 else defaultOpts
789 else defaultOpts
789
790
790 -- thread option data structure through all supplied option actions
791 -- thread option data structure through all supplied option actions
@@ -819,7 +820,6 @@ main = do
819 , optEPUBFonts = epubFonts
820 , optEPUBFonts = epubFonts
820 , optDumpArgs = dumpArgs
821 , optDumpArgs = dumpArgs
821 , optIgnoreArgs = ignoreArgs
822 , optIgnoreArgs = ignoreArgs
822− , optStrict = strict
823 , optReferenceLinks = referenceLinks
823 , optReferenceLinks = referenceLinks
824 , optWrapText = wrap
824 , optWrapText = wrap
825 , optColumns = columns
825 , optColumns = columns
@@ -867,8 +867,8 @@ main = do
867
867
868 let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
868 let pdfOutput = map toLower (takeExtension outputFile) == ".pdf"
869
869
870− let laTeXOutput = writerName' == "latex" || writerName' == "beamer" ||
870+ let laTeXOutput = "latex" `isPrefixOf` writerName' ||
871− writerName' == "latex+lhs" || writerName' == "beamer+lhs"
871+ "beamer" `isPrefixOf` writerName'
872
872
873 when pdfOutput $ do
873 when pdfOutput $ do
874 -- make sure writer is latex or beamer
874 -- make sure writer is latex or beamer
@@ -882,11 +882,11 @@ main = do
882 latexEngine ++ " is needed for pdf output."
882 latexEngine ++ " is needed for pdf output."
883 Just _ -> return ()
883 Just _ -> return ()
884
884
885− reader <- case (lookup readerName' readers) of
885+ reader <- case getReader readerName' of
886− Just r -> return r
886+ Right r -> return r
887− Nothing -> err 7 ("Unknown reader: " ++ readerName')
887+ Left e -> err 7 e
888
888
889− let standalone' = standalone || writerName' `elem` nonTextFormats || pdfOutput
889+ let standalone' = standalone || not (isTextFormat writerName') || pdfOutput
890
890
891 templ <- case templatePath of
891 templ <- case templatePath of
892 _ | not standalone' -> return ""
892 _ | not standalone' -> return ""
@@ -896,8 +896,8 @@ main = do
896 Left e -> throwIO e
896 Left e -> throwIO e
897 Right t -> return t
897 Right t -> return t
898 Just tp -> do
898 Just tp -> do
899− -- strip off "+lhs" if present
899+ -- strip off extensions
900− let format = takeWhile (/='+') writerName'
900+ let format = takeWhile (`notElem` "+-") writerName'
901 let tp' = case takeExtension tp of
901 let tp' = case takeExtension tp of
902 "" -> tp <.> format
902 "" -> tp <.> format
903 _ -> tp
903 _ -> tp
@@ -919,13 +919,13 @@ main = do
919 return $ ("mathml-script", s) : variables
919 return $ ("mathml-script", s) : variables
920 _ -> return variables
920 _ -> return variables
921
921
922− variables'' <- case writerName' of
922+ variables'' <- if "dzslides" `isPrefixOf` writerName'
923− "dzslides" -> do
923+ then do
924 dztempl <- readDataFile datadir $ "dzslides" </> "template.html"
924 dztempl <- readDataFile datadir $ "dzslides" </> "template.html"
925 let dzcore = unlines $ dropWhile (not . isPrefixOf "<!-- {{{{ dzslides core")
925 let dzcore = unlines $ dropWhile (not . isPrefixOf "<!-- {{{{ dzslides core")
926 $ lines dztempl
926 $ lines dztempl
927 return $ ("dzslides-core", dzcore) : variables'
927 return $ ("dzslides-core", dzcore) : variables'
928− _ -> return variables'
928+ else return variables'
929
929
930 -- unescape reference ids, which may contain XML entities, so
930 -- unescape reference ids, which may contain XML entities, so
931 -- that we can do lookups with regular string equality
931 -- that we can do lookups with regular string equality
@@ -942,13 +942,8 @@ main = do
942 then "."
942 then "."
943 else takeDirectory (head sources)
943 else takeDirectory (head sources)
944
944
945− let defaultExts = if strict
946− then strictExtensions
947− else pandocExtensions
948−
949− let readerOpts = def{ readerExtensions = defaultExts
950− , readerSmart = smart || (texLigatures &&
945+ let readerOpts = def{ readerSmart = smart || (texLigatures &&
951− (laTeXOutput || writerName' == "context"))
946+ (laTeXOutput || "context" `isPrefixOf` writerName'))
952 , readerStandalone = standalone'
947 , readerStandalone = standalone'
953 , readerParseRaw = parseRaw
948 , readerParseRaw = parseRaw
954 , readerColumns = columns
949 , readerColumns = columns
@@ -972,13 +967,10 @@ main = do
972 writerIgnoreNotes = False,
967 writerIgnoreNotes = False,
973 writerNumberSections = numberSections,
968 writerNumberSections = numberSections,
974 writerSectionDivs = sectionDivs,
969 writerSectionDivs = sectionDivs,
975− writerExtensions = defaultExts,
976 writerReferenceLinks = referenceLinks,
970 writerReferenceLinks = referenceLinks,
977 writerWrapText = wrap,
971 writerWrapText = wrap,
978 writerColumns = columns,
972 writerColumns = columns,
979− writerEmailObfuscation = if strict
973+ writerEmailObfuscation = obfuscationMethod,
980− then ReferenceObfuscation
981− else obfuscationMethod,
982 writerIdentifierPrefix = idPrefix,
974 writerIdentifierPrefix = idPrefix,
983 writerSourceDirectory = sourceDir,
975 writerSourceDirectory = sourceDir,
984 writerUserDataDir = datadir,
976 writerUserDataDir = datadir,
@@ -997,7 +989,7 @@ main = do
997 writerReferenceDocx = referenceDocx
989 writerReferenceDocx = referenceDocx
998 }
990 }
999
991
1000− when (writerName' `elem` nonTextFormats&& outputFile == "-") $
992+ when (not (isTextFormat writerName') && outputFile == "-") $
1001 err 5 $ "Cannot write " ++ writerName' ++ " output to stdout.\n" ++
993 err 5 $ "Cannot write " ++ writerName' ++ " output to stdout.\n" ++
1002 "Specify an output file using the -o option."
994 "Specify an output file using the -o option."
1003
995
@@ -1022,7 +1014,7 @@ main = do
1022
1014
1023 let doc0 = foldr ($) doc transforms
1015 let doc0 = foldr ($) doc transforms
1024
1016
1025− doc1 <- if writerName' == "rtf"
1017+ doc1 <- if "rtf" `isPrefixOf` writerName'
1026 then bottomUpM rtfEmbedImage doc0
1018 then bottomUpM rtfEmbedImage doc0
1027 else return doc0
1019 else return doc0
1028
1020
@@ -1050,12 +1042,11 @@ main = do
1050 writerFn "-" = UTF8.putStr
1042 writerFn "-" = UTF8.putStr
1051 writerFn f = UTF8.writeFile f
1043 writerFn f = UTF8.writeFile f
1052
1044
1053− let mbwriter = lookup writerName' writers
1045+ case getWriter writerName' of
1054− case mbwriter of
1046+ Left e -> err 9 e
1055− Nothing -> err 9 ("Unknown writer: " ++ writerName')
1056− Just (IOStringWriter f) -> f writerOptions doc2 >>= writerFn outputFile
1047+ Right (IOStringWriter f) -> f writerOptions doc2 >>= writerFn outputFile
1057− Just (IOByteStringWriter f) -> f writerOptions doc2 >>= writeBinary
1048+ Right (IOByteStringWriter f) -> f writerOptions doc2 >>= writeBinary
1058− Just (PureStringWriter f)
1049+ Right (PureStringWriter f)
1059 | pdfOutput -> do
1050 | pdfOutput -> do
1060 res <- tex2pdf latexEngine $ f writerOptions doc2
1051 res <- tex2pdf latexEngine $ f writerOptions doc2
1061 case res of
1052 case res of