@@ -141,95 +141,15 @@ options =
141141 "FILE")
142142 "" -- "Name of output file"
143143
144− , Option "" ["data-dir"]
145− (ReqArg
146− (\arg opt -> return opt { optDataDir =
147− Just (normalizePath arg) })
148− "DIRECTORY") -- "Directory containing pandoc data files."
149− ""
150−
151− , Option "" ["base-header-level"]
152− (ReqArg
153− (\arg opt ->
154− case safeRead arg of
155− Just t | t > 0 && t < 6 ->
156− return opt{ optBaseHeaderLevel = t }
157− _ -> E.throwIO $ PandocOptionError
158− "base-header-level must be 1-5")
159− "NUMBER")
160− "" -- "Headers base level"
161−
162− , Option "" ["strip-empty-paragraphs"]
163− (NoArg
164− (\opt -> do
165− deprecatedOption "--stripEmptyParagraphs"
166− "Use +empty_paragraphs extension."
167− return opt{ optStripEmptyParagraphs = True }))
168− "" -- "Strip empty paragraphs"
169−
170− , Option "" ["indented-code-classes"]
171− (ReqArg
172− (\arg opt -> return opt { optIndentedCodeClasses = words $
173− map (\c -> if c == ',' then ' ' else c) arg })
174− "STRING")
175− "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"
176−
177− , Option "F" ["filter"]
178− (ReqArg
179− (\arg opt -> return opt { optFilters =
180− JSONFilter (normalizePath arg) :
181− optFilters opt })
182− "PROGRAM")
183− "" -- "External JSON filter"
184−
185− , Option "" ["lua-filter"]
186− (ReqArg
187− (\arg opt -> return opt { optFilters =
188− LuaFilter (normalizePath arg) :
189− optFilters opt })
190− "SCRIPTPATH")
191− "" -- "Lua filter"
192−
193− , Option "p" ["preserve-tabs"]
194− (NoArg
195− (\opt -> return opt { optPreserveTabs = True }))
196− "" -- "Preserve tabs instead of converting to spaces"
197−
198− , Option "" ["tab-stop"]
199− (ReqArg
200− (\arg opt ->
201− case safeRead arg of
202− Just t | t > 0 -> return opt { optTabStop = t }
203− _ -> E.throwIO $ PandocOptionError
204− "tab-stop must be a number greater than 0")
205− "NUMBER")
206− "" -- "Tab stop (default 4)"
207−
208− , Option "" ["track-changes"]
209− (ReqArg
210− (\arg opt -> do
211− action <- case arg of
212− "accept" -> return AcceptChanges
213− "reject" -> return RejectChanges
214− "all" -> return AllChanges
215− _ -> E.throwIO $ PandocOptionError
216− ("Unknown option for track-changes: " ++ arg)
217− return opt { optTrackChanges = action })
218− "accept|reject|all")
219− "" -- "Accepting or reject MS Word track-changes.""
220−
221− , Option "" ["file-scope"]
222− (NoArg
223− (\opt -> return opt { optFileScope = True }))
224− "" -- "Parse input files before combining"
225−
226− , Option "" ["extract-media"]
144+ , Option "" ["wrap"]
227145 (ReqArg
228146 (\arg opt ->
229− return opt { optExtractMedia =
230− Just (normalizePath arg) })
231− "PATH")
232− "" -- "Directory to which to extract embedded media"
147+ case safeRead ("Wrap" ++ uppercaseFirstLetter arg) of
148+ Just o -> return opt { optWrapText = o }
149+ Nothing -> E.throwIO $ PandocOptionError
150+ "--wrap must be auto, none, or preserve")
151+ "auto|none|preserve")
152+ "" -- "Option for wrapping text in output"
233153
234154 , Option "s" ["standalone"]
235155 (NoArg
@@ -244,6 +164,13 @@ options =
244164 "FILE")
245165 "" -- "Use custom template"
246166
167+ , Option "" ["data-dir"]
168+ (ReqArg
169+ (\arg opt -> return opt { optDataDir =
170+ Just (normalizePath arg) })
171+ "DIRECTORY") -- "Directory containing pandoc data files."
172+ ""
173+
247174 , Option "M" ["metadata"]
248175 (ReqArg
249176 (\arg opt -> do
@@ -267,100 +194,10 @@ options =
267194 "KEY[:VALUE]")
268195 ""
269196
270− , Option "D" ["print-default-template"]
271− (ReqArg
272− (\arg _ -> do
273− templ <- runIO $ do
274− setUserDataDir Nothing
275− getDefaultTemplate arg
276− case templ of
277− Right "" -> -- e.g. for docx, odt, json:
278− E.throwIO $ PandocCouldNotFindDataFileError
279− ("templates/default." ++ arg)
280− Right t -> UTF8.hPutStr stdout t
281− Left e -> E.throwIO e
282− exitSuccess)
283− "FORMAT")
284− "" -- "Print default template for FORMAT"
285−
286− , Option "" ["print-default-data-file"]
287− (ReqArg
288− (\arg _ -> do
289− runIOorExplode $
290− readDefaultDataFile arg >>= liftIO . BS.hPutStr stdout
291− exitSuccess)
292− "FILE")
293− "" -- "Print default data file"
294−
295− , Option "" ["print-highlight-style"]
296− (ReqArg
297− (\arg _ -> do
298− sty <- fromMaybe pygments <$> lookupHighlightStyle arg
299− B.putStr $ encodePretty'
300− defConfig{confIndent = Spaces 4
301− ,confCompare = keyOrder
302− (map T.pack
303− ["text-color"
304− ,"background-color"
305− ,"line-number-color"
306− ,"line-number-background-color"
307− ,"bold"
308− ,"italic"
309− ,"underline"
310− ,"text-styles"])
311− ,confNumFormat = Generic
312− ,confTrailingNewline = True} sty
313− exitSuccess)
314− "STYLE|FILE")
315− "" -- "Print default template for FORMAT"
316−
317− , Option "" ["dpi"]
318− (ReqArg
319− (\arg opt ->
320− case safeRead arg of
321− Just t | t > 0 -> return opt { optDpi = t }
322− _ -> E.throwIO $ PandocOptionError
323− "dpi must be a number greater than 0")
324− "NUMBER")
325− "" -- "Dpi (default 96)"
326−
327− , Option "" ["eol"]
328− (ReqArg
329− (\arg opt ->
330− case toLower <$> arg of
331− "crlf" -> return opt { optEol = CRLF }
332− "lf" -> return opt { optEol = LF }
333− "native" -> return opt { optEol = Native }
334− -- mac-syntax (cr) is not supported in ghc-base.
335− _ -> E.throwIO $ PandocOptionError
336− "--eol must be crlf, lf, or native")
337− "crlf|lf|native")
338− "" -- "EOL (default OS-dependent)"
339−
340− , Option "" ["wrap"]
341− (ReqArg
342− (\arg opt ->
343− case safeRead ("Wrap" ++ uppercaseFirstLetter arg) of
344− Just o -> return opt { optWrapText = o }
345− Nothing -> E.throwIO $ PandocOptionError
346− "--wrap must be auto, none, or preserve")
347− "auto|none|preserve")
348− "" -- "Option for wrapping text in output"
349−
350− , Option "" ["columns"]
351− (ReqArg
352− (\arg opt ->
353− case safeRead arg of
354− Just t | t > 0 -> return opt { optColumns = t }
355− _ -> E.throwIO $ PandocOptionError
356− "columns must be a number greater than 0")
357− "NUMBER")
358− "" -- "Length of line in characters"
359−
360− , Option "" ["strip-comments"]
361− (NoArg
362− (\opt -> return opt { optStripComments = True }))
363− "" -- "Strip HTML comments"
197+ , Option "" ["ascii"]
198+ (NoArg
199+ (\opt -> return opt { optAscii = True }))
200+ "" -- "Prefer ASCII output"
364201
365202 , Option "" ["toc", "table-of-contents"]
366203 (NoArg
@@ -378,6 +215,73 @@ options =
378215 "NUMBER")
379216 "" -- "Number of levels to include in TOC"
380217
218+ , Option "N" ["number-sections"]
219+ (NoArg
220+ (\opt -> return opt { optNumberSections = True }))
221+ "" -- "Number sections in LaTeX"
222+
223+ , Option "" ["number-offset"]
224+ (ReqArg
225+ (\arg opt ->
226+ case safeRead ('[':arg ++ "]") of
227+ Just ns -> return opt { optNumberOffset = ns,
228+ optNumberSections = True }
229+ _ -> E.throwIO $ PandocOptionError
230+ "could not parse number-offset")
231+ "NUMBERS")
232+ "" -- "Starting number for sections, subsections, etc."
233+
234+ , Option "" ["top-level-division"]
235+ (ReqArg
236+ (\arg opt -> do
237+ let tldName = "TopLevel" ++ uppercaseFirstLetter arg
238+ case safeRead tldName of
239+ Just tlDiv -> return opt { optTopLevelDivision = tlDiv }
240+ _ -> E.throwIO $ PandocOptionError
241+ ("Top-level division must be " ++
242+ "section, chapter, part, or default"))
243+ "section|chapter|part")
244+ "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"
245+
246+ , Option "" ["extract-media"]
247+ (ReqArg
248+ (\arg opt ->
249+ return opt { optExtractMedia =
250+ Just (normalizePath arg) })
251+ "PATH")
252+ "" -- "Directory to which to extract embedded media"
253+
254+ , Option "" ["resource-path"]
255+ (ReqArg
256+ (\arg opt -> return opt { optResourcePath =
257+ splitSearchPath arg })
258+ "SEARCHPATH")
259+ "" -- "Paths to search for images and other resources"
260+
261+ , Option "H" ["include-in-header"]
262+ (ReqArg
263+ (\arg opt -> return opt{ optIncludeInHeader =
264+ arg : optIncludeInHeader opt,
265+ optStandalone = True })
266+ "FILE")
267+ "" -- "File to include at end of header (implies -s)"
268+
269+ , Option "B" ["include-before-body"]
270+ (ReqArg
271+ (\arg opt -> return opt{ optIncludeBeforeBody =
272+ arg : optIncludeBeforeBody opt,
273+ optStandalone = True })
274+ "FILE")
275+ "" -- "File to include before document body"
276+
277+ , Option "A" ["include-after-body"]
278+ (ReqArg
279+ (\arg opt -> return opt{ optIncludeAfterBody =
280+ arg : optIncludeAfterBody opt,
281+ optStandalone = True })
282+ "FILE")
283+ "" -- "File to include after document body"
284+
381285 , Option "" ["no-highlight"]
382286 (NoArg
383287 (\opt -> return opt { optHighlightStyle = Nothing }))
@@ -404,36 +308,85 @@ options =
404308 "FILE")
405309 "" -- "Syntax definition (xml) file"
406310
407− , Option "H" ["include-in-header"]
311+ , Option "" ["dpi"]
312+ (ReqArg
313+ (\arg opt ->
314+ case safeRead arg of
315+ Just t | t > 0 -> return opt { optDpi = t }
316+ _ -> E.throwIO $ PandocOptionError
317+ "dpi must be a number greater than 0")
318+ "NUMBER")
319+ "" -- "Dpi (default 96)"
320+
321+ , Option "" ["eol"]
322+ (ReqArg
323+ (\arg opt ->
324+ case toLower <$> arg of
325+ "crlf" -> return opt { optEol = CRLF }
326+ "lf" -> return opt { optEol = LF }
327+ "native" -> return opt { optEol = Native }
328+ -- mac-syntax (cr) is not supported in ghc-base.
329+ _ -> E.throwIO $ PandocOptionError
330+ "--eol must be crlf, lf, or native")
331+ "crlf|lf|native")
332+ "" -- "EOL (default OS-dependent)"
333+
334+ , Option "" ["columns"]
335+ (ReqArg
336+ (\arg opt ->
337+ case safeRead arg of
338+ Just t | t > 0 -> return opt { optColumns = t }
339+ _ -> E.throwIO $ PandocOptionError
340+ "columns must be a number greater than 0")
341+ "NUMBER")
342+ "" -- "Length of line in characters"
343+
344+ , Option "p" ["preserve-tabs"]
345+ (NoArg
346+ (\opt -> return opt { optPreserveTabs = True }))
347+ "" -- "Preserve tabs instead of converting to spaces"
348+
349+ , Option "" ["tab-stop"]
350+ (ReqArg
351+ (\arg opt ->
352+ case safeRead arg of
353+ Just t | t > 0 -> return opt { optTabStop = t }
354+ _ -> E.throwIO $ PandocOptionError
355+ "tab-stop must be a number greater than 0")
356+ "NUMBER")
357+ "" -- "Tab stop (default 4)"
358+
359+ , Option "" ["pdf-engine"]
408360 (ReqArg
409− (\arg opt -> return opt{ optIncludeInHeader =
410− arg : optIncludeInHeader opt,
411− optStandalone = True })
412− "FILE")
413− "" -- "File to include at end of header (implies -s)"
361+ (\arg opt -> do
362+ let b = takeBaseName arg
363+ if b `elem` pdfEngines
364+ then return opt { optPdfEngine = Just arg }
365+ else E.throwIO $ PandocOptionError $ "pdf-engine must be one of "
366+ ++ intercalate ", " pdfEngines)
367+ "PROGRAM")
368+ "" -- "Name of program to use in generating PDF"
414369
415− , Option "B" ["include-before-body"]
370+ , Option "" ["pdf-engine-opt"]
416371 (ReqArg
417− (\arg opt -> return opt{ optIncludeBeforeBody =
418− arg : optIncludeBeforeBody opt,
419− optStandalone = True })
420− "FILE")
421− "" -- "File to include before document body"
372+ (\arg opt -> do
373+ let oldArgs = optPdfEngineArgs opt
374+ return opt { optPdfEngineArgs = oldArgs ++ [arg]})
375+ "STRING")
376+ "" -- "Flags to pass to the PDF-engine, all instances of this option are accumulated and used"
422377
423− , Option "A" ["include-after-body"]
378+ , Option "" ["reference-doc"]
424379 (ReqArg
425− (\arg opt -> return opt{ optIncludeAfterBody =
426− arg : optIncludeAfterBody opt,
427− optStandalone = True })
380+ (\arg opt ->
381+ return opt { optReferenceDoc = Just arg })
428382 "FILE")
429− "" -- "File to include after document body"
383+ "" -- "Path of custom reference doc"
430384
431− , Option "" ["resource-path"]
432− (ReqArg
433− (\arg opt -> return opt { optResourcePath =
434− splitSearchPath arg })
435− "SEARCHPATH")
436− "" -- "Paths to search for images and other resources"
385+ , Option "" ["self-contained"]
386+ (NoArg
387+ (\opt -> return opt { optSelfContained = True,
388+ optStandalone = True }))
389+ "" -- "Make slide shows include all the needed js and css"
437390
438391 , Option "" ["request-header"]
439392 (ReqArg
@@ -444,22 +397,82 @@ options =
444397 "NAME:VALUE")
445398 ""
446399
447− , Option "" ["self-contained"]
400+ , Option "" ["file-scope"]
448401 (NoArg
449− (\opt -> return opt { optSelfContained = True,
450− optStandalone = True }))
451− "" -- "Make slide shows include all the needed js and css"
402+ (\opt -> return opt { optFileScope = True }))
403+ "" -- "Parse input files before combining"
452404
453− , Option "" ["html-q-tags"]
454− (NoArg
455− (\opt ->
456− return opt { optHtmlQTags = True }))
457− "" -- "Use <q> tags for quotes in HTML"
405+ , Option "" ["abbreviations"]
406+ (ReqArg
407+ (\arg opt -> return opt { optAbbreviations = Just arg })
408+ "FILE")
409+ "" -- "Specify file for custom abbreviations"
458410
459− , Option "" ["ascii"]
411+ , Option "" ["indented-code-classes"]
412+ (ReqArg
413+ (\arg opt -> return opt { optIndentedCodeClasses = words $
414+ map (\c -> if c == ',' then ' ' else c) arg })
415+ "STRING")
416+ "" -- "Classes (whitespace- or comma-separated) to use for indented code-blocks"
417+
418+ , Option "" ["default-image-extension"]
419+ (ReqArg
420+ (\arg opt -> return opt { optDefaultImageExtension = arg })
421+ "extension")
422+ "" -- "Default extension for extensionless images"
423+
424+ , Option "F" ["filter"]
425+ (ReqArg
426+ (\arg opt -> return opt { optFilters =
427+ JSONFilter (normalizePath arg) :
428+ optFilters opt })
429+ "PROGRAM")
430+ "" -- "External JSON filter"
431+
432+ , Option "" ["lua-filter"]
433+ (ReqArg
434+ (\arg opt -> return opt { optFilters =
435+ LuaFilter (normalizePath arg) :
436+ optFilters opt })
437+ "SCRIPTPATH")
438+ "" -- "Lua filter"
439+
440+ , Option "" ["base-header-level"]
441+ (ReqArg
442+ (\arg opt ->
443+ case safeRead arg of
444+ Just t | t > 0 && t < 6 ->
445+ return opt{ optBaseHeaderLevel = t }
446+ _ -> E.throwIO $ PandocOptionError
447+ "base-header-level must be 1-5")
448+ "NUMBER")
449+ "" -- "Headers base level"
450+
451+ , Option "" ["strip-empty-paragraphs"]
460452 (NoArg
461− (\opt -> return opt { optAscii = True }))
462− "" -- "Prefer ASCII output"
453+ (\opt -> do
454+ deprecatedOption "--stripEmptyParagraphs"
455+ "Use +empty_paragraphs extension."
456+ return opt{ optStripEmptyParagraphs = True }))
457+ "" -- "Strip empty paragraphs"
458+
459+ , Option "" ["track-changes"]
460+ (ReqArg
461+ (\arg opt -> do
462+ action <- case arg of
463+ "accept" -> return AcceptChanges
464+ "reject" -> return RejectChanges
465+ "all" -> return AllChanges
466+ _ -> E.throwIO $ PandocOptionError
467+ ("Unknown option for track-changes: " ++ arg)
468+ return opt { optTrackChanges = action })
469+ "accept|reject|all")
470+ "" -- "Accepting or reject MS Word track-changes.""
471+
472+ , Option "" ["strip-comments"]
473+ (NoArg
474+ (\opt -> return opt { optStripComments = True }))
475+ "" -- "Strip HTML comments"
463476
464477 , Option "" ["reference-links"]
465478 (NoArg
@@ -484,34 +497,6 @@ options =
484497 (\opt -> return opt { optSetextHeaders = False } ))
485498 "" -- "Use atx-style headers for markdown"
486499
487− , Option "" ["top-level-division"]
488− (ReqArg
489− (\arg opt -> do
490− let tldName = "TopLevel" ++ uppercaseFirstLetter arg
491− case safeRead tldName of
492− Just tlDiv -> return opt { optTopLevelDivision = tlDiv }
493− _ -> E.throwIO $ PandocOptionError
494− ("Top-level division must be " ++
495− "section, chapter, part, or default"))
496− "section|chapter|part")
497− "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"
498−
499− , Option "N" ["number-sections"]
500− (NoArg
501− (\opt -> return opt { optNumberSections = True }))
502− "" -- "Number sections in LaTeX"
503−
504− , Option "" ["number-offset"]
505− (ReqArg
506− (\arg opt ->
507− case safeRead ('[':arg ++ "]") of
508− Just ns -> return opt { optNumberOffset = ns,
509− optNumberSections = True }
510− _ -> E.throwIO $ PandocOptionError
511− "could not parse number-offset")
512− "NUMBERS")
513− "" -- "Starting number for sections, subsections, etc."
514−
515500 , Option "" ["listings"]
516501 (NoArg
517502 (\opt -> return opt { optListings = True }))
@@ -538,11 +523,11 @@ options =
538523 (\opt -> return opt { optSectionDivs = True }))
539524 "" -- "Put sections in div tags in HTML"
540525
541− , Option "" ["default-image-extension"]
542− (ReqArg
543− (\arg opt -> return opt { optDefaultImageExtension = arg })
544− "extension")
545− "" -- "Default extension for extensionless images"
526+ , Option "" ["html-q-tags"]
527+ (NoArg
528+ (\opt ->
529+ return opt { optHtmlQTags = True }))
530+ "" -- "Use <q> tags for quotes in HTML"
546531
547532 , Option "" ["email-obfuscation"]
548533 (ReqArg
@@ -579,13 +564,6 @@ options =
579564 "URL")
580565 "" -- "Link to CSS style sheet"
581566
582− , Option "" ["reference-doc"]
583− (ReqArg
584− (\arg opt ->
585− return opt { optReferenceDoc = Just arg })
586− "FILE")
587− "" -- "Path of custom reference doc"
588−
589567 , Option "" ["epub-subdirectory"]
590568 (ReqArg
591569 (\arg opt ->
@@ -635,25 +613,6 @@ options =
635613 "all|none|best")
636614 "" -- "Starting number for sections, subsections, etc."
637615
638− , Option "" ["pdf-engine"]
639− (ReqArg
640− (\arg opt -> do
641− let b = takeBaseName arg
642− if b `elem` pdfEngines
643− then return opt { optPdfEngine = Just arg }
644− else E.throwIO $ PandocOptionError $ "pdf-engine must be one of "
645− ++ intercalate ", " pdfEngines)
646− "PROGRAM")
647− "" -- "Name of program to use in generating PDF"
648−
649− , Option "" ["pdf-engine-opt"]
650− (ReqArg
651− (\arg opt -> do
652− let oldArgs = optPdfEngineArgs opt
653− return opt { optPdfEngineArgs = oldArgs ++ [arg]})
654− "STRING")
655− "" -- "Flags to pass to the PDF-engine, all instances of this option are accumulated and used"
656−
657616 , Option "" ["bibliography"]
658617 (ReqArg
659618 (\arg opt -> return opt{ optMetadata =
@@ -725,12 +684,6 @@ options =
725684 return opt { optHTMLMathMethod = GladTeX }))
726685 "" -- "Use gladtex for HTML math"
727686
728− , Option "" ["abbreviations"]
729− (ReqArg
730− (\arg opt -> return opt { optAbbreviations = Just arg })
731− "FILE")
732− "" -- "Specify file for custom abbreviations"
733−
734687 , Option "" ["trace"]
735688 (NoArg
736689 (\opt -> return opt { optTrace = True }))
@@ -832,6 +785,54 @@ options =
832785 exitSuccess ))
833786 ""
834787
788+ , Option "D" ["print-default-template"]
789+ (ReqArg
790+ (\arg _ -> do
791+ templ <- runIO $ do
792+ setUserDataDir Nothing
793+ getDefaultTemplate arg
794+ case templ of
795+ Right "" -> -- e.g. for docx, odt, json:
796+ E.throwIO $ PandocCouldNotFindDataFileError
797+ ("templates/default." ++ arg)
798+ Right t -> UTF8.hPutStr stdout t
799+ Left e -> E.throwIO e
800+ exitSuccess)
801+ "FORMAT")
802+ "" -- "Print default template for FORMAT"
803+
804+ , Option "" ["print-default-data-file"]
805+ (ReqArg
806+ (\arg _ -> do
807+ runIOorExplode $
808+ readDefaultDataFile arg >>= liftIO . BS.hPutStr stdout
809+ exitSuccess)
810+ "FILE")
811+ "" -- "Print default data file"
812+
813+ , Option "" ["print-highlight-style"]
814+ (ReqArg
815+ (\arg _ -> do
816+ sty <- fromMaybe pygments <$> lookupHighlightStyle arg
817+ B.putStr $ encodePretty'
818+ defConfig{confIndent = Spaces 4
819+ ,confCompare = keyOrder
820+ (map T.pack
821+ ["text-color"
822+ ,"background-color"
823+ ,"line-number-color"
824+ ,"line-number-background-color"
825+ ,"bold"
826+ ,"italic"
827+ ,"underline"
828+ ,"text-styles"])
829+ ,confNumFormat = Generic
830+ ,confTrailingNewline = True} sty
831+ exitSuccess)
832+ "STYLE|FILE")
833+ "" -- "Print default template for FORMAT"
834+
835+
835836 , Option "v" ["version"]
836837 (NoArg
837838 (\_ -> do