git.iko.soy/typeable/pandoc
on master help sign in
Allow -o/--output to be used with --print-*.
bf4a164John MacFarlane
MANUAL.txt+23−16
@@ -695,12 +695,17 @@ General writer options {.options}
695
695
696: Print the system default template for an output *FORMAT*. (See `-t`
696: Print the system default template for an output *FORMAT*. (See `-t`
697 for a list of possible *FORMAT*s.) Templates in the user data
697 for a list of possible *FORMAT*s.) Templates in the user data
698− directory are ignored.
698+ directory are ignored. This option may be used with
699+ `-o`/`--output` to redirect output to a file, but
700+ `-o`/`--output` must come before `--print-default-template`
701+ on the command line.
699
702
700`--print-default-data-file=`*FILE*
703`--print-default-data-file=`*FILE*
701
704
702: Print a system default data file. Files in the user data directory
705: Print a system default data file. Files in the user data directory
703− are ignored.
706+ are ignored. This option may be used with `-o`/`--output` to
707+ redirect output to a file, but `-o`/`--output` must come before
708+ `--print-default-data-file` on the command line.
704
709
705`--eol=crlf`|`lf`|`native`
710`--eol=crlf`|`lf`|`native`
706
711
@@ -784,7 +789,10 @@ General writer options {.options}
784
789
785: Prints a JSON version of a highlighting style, which can
790: Prints a JSON version of a highlighting style, which can
786 be modified, saved with a `.theme` extension, and used
791 be modified, saved with a `.theme` extension, and used
787− with `--highlight-style`.
792+ with `--highlight-style`. This option may be used with
793+ `-o`/`--output` to redirect output to a file, but
794+ `-o`/`--output` must come before `--print-highlight-style`
795+ on the command line.
788
796
789`--syntax-definition=`*FILE*
797`--syntax-definition=`*FILE*
790
798
@@ -1016,11 +1024,11 @@ Options affecting specific writers {.options}
1016
1024
1017 To produce a custom `reference.docx`, first get a copy of
1025 To produce a custom `reference.docx`, first get a copy of
1018 the default `reference.docx`: `pandoc
1026 the default `reference.docx`: `pandoc
1019− --print-default-data-file reference.docx >
1027+ -o custom-reference.docx --print-default-data-file reference.docx`.
1020− custom-reference.docx`. Then open `custom-reference.docx`
1028+ Then open `custom-reference.docx` in Word, modify the
1021− in Word, modify the styles as you wish, and save the file.
1029+ styles as you wish, and save the file. For best
1022− For best results, do not make changes to this file other
1030+ results, do not make changes to this file other than
1023− than modifying the styles used by pandoc:
1031+ modifying the styles used by pandoc:
1024
1032
1025 Paragraph styles:
1033 Paragraph styles:
1026
1034
@@ -1078,10 +1086,9 @@ Options affecting specific writers {.options}
1078
1086
1079 To produce a custom `reference.odt`, first get a copy of
1087 To produce a custom `reference.odt`, first get a copy of
1080 the default `reference.odt`: `pandoc
1088 the default `reference.odt`: `pandoc
1081− --print-default-data-file reference.odt >
1089+ -o custom-reference.odt --print-default-data-file reference.odt`.
1082− custom-reference.odt`. Then open `custom-reference.odt` in
1090+ Then open `custom-reference.odt` in LibreOffice, modify
1083− LibreOffice, modify the styles as you wish, and save the
1091+ the styles as you wish, and save the file.
1084− file.
1085
1092
1086 PowerPoint
1093 PowerPoint
1087
1094
@@ -1102,10 +1109,10 @@ Options affecting specific writers {.options}
1102 `Home` menu to check.)
1109 `Home` menu to check.)
1103
1110
1104 You can also modify the default `reference.pptx`: first run
1111 You can also modify the default `reference.pptx`: first run
1105− `pandoc --print-default-data-file reference.pptx >
1112+ `pandoc -o custom-reference.pptx --print-default-data-file
1106− custom-reference.pptx`, and then modify
1113+ reference.pptx`, and then modify `custom-reference.pptx`
1107− `custom-reference.pptx` in MS PowerPoint (pandoc will use the
1114+ in MS PowerPoint (pandoc will use the first four layout
1108− first four layout slides, as mentioned above).
1115+ slides, as mentioned above).
1109
1116
1110`--epub-cover-image=`*FILE*
1117`--epub-cover-image=`*FILE*
1111
1118
src/Text/Pandoc/App/CommandLineOptions.hs+15−6
@@ -786,7 +786,10 @@ options =
786
786
787 , Option "D" ["print-default-template"]
787 , Option "D" ["print-default-template"]
788 (ReqArg
788 (ReqArg
789− (\arg _ -> do
789+ (\arg opt -> do
790+ let write = case optOutputFile opt of
791+ Just f -> UTF8.writeFile f
792+ Nothing -> UTF8.hPutStr stdout
790 templ <- runIO $ do
793 templ <- runIO $ do
791 setUserDataDir Nothing
794 setUserDataDir Nothing
792 getDefaultTemplate arg
795 getDefaultTemplate arg
@@ -794,7 +797,7 @@ options =
794 Right "" -> -- e.g. for docx, odt, json:
797 Right "" -> -- e.g. for docx, odt, json:
795 E.throwIO $ PandocCouldNotFindDataFileError
798 E.throwIO $ PandocCouldNotFindDataFileError
796 ("templates/default." ++ arg)
799 ("templates/default." ++ arg)
797− Right t -> UTF8.hPutStr stdout t
800+ Right t -> write t
798 Left e -> E.throwIO e
801 Left e -> E.throwIO e
799 exitSuccess)
802 exitSuccess)
800 "FORMAT")
803 "FORMAT")
@@ -802,18 +805,24 @@ options =
802
805
803 , Option "" ["print-default-data-file"]
806 , Option "" ["print-default-data-file"]
804 (ReqArg
807 (ReqArg
805− (\arg _ -> do
808+ (\arg opt -> do
809+ let write = case optOutputFile opt of
810+ Just f -> BS.writeFile f
811+ Nothing -> BS.hPutStr stdout
806 runIOorExplode $
812 runIOorExplode $
807− readDefaultDataFile arg >>= liftIO . BS.hPutStr stdout
813+ readDefaultDataFile arg >>= liftIO . write
808 exitSuccess)
814 exitSuccess)
809 "FILE")
815 "FILE")
810 "" -- "Print default data file"
816 "" -- "Print default data file"
811
817
812 , Option "" ["print-highlight-style"]
818 , Option "" ["print-highlight-style"]
813 (ReqArg
819 (ReqArg
814− (\arg _ -> do
820+ (\arg opt -> do
821+ let write = case optOutputFile opt of
822+ Just f -> B.writeFile f
823+ Nothing -> B.putStr
815 sty <- fromMaybe pygments <$> lookupHighlightStyle arg
824 sty <- fromMaybe pygments <$> lookupHighlightStyle arg
816− B.putStr $ encodePretty'
825+ write $ encodePretty'
817 defConfig{confIndent = Spaces 4
826 defConfig{confIndent = Spaces 4
818 ,confCompare = keyOrder
827 ,confCompare = keyOrder
819 (map T.pack
828 (map T.pack