git.iko.soy/typeable/pandoc
on master help sign in
Simplified reference-docx/reference-odt to reference-doc.

* Text.Pandoc.Options.WriterOptions: removed writerReferenceDocx and writerReferenceODT, replaced them with writerReferenceDoc. This can hold either an ODT or a Docx. In this way, writerReferenceDoc is like writerTemplate, which can hold templates of different formats. [API change] * Removed `--reference-docx` and `--reference-odt` options. * Added `--reference-doc` option.

commitce1664cf2ba29c8b973d7a228744b43144c0859d authorJohn MacFarlane <jgm@berkeley.edu> dateSat 10 Dec 2016, 10:39 (10 years ago) parent9570f59
6 files changed+49−62
MANUAL.txt+37−37 pandoc.hs+7−18 src/Text/Pandoc/Options.hs+2−4 src/Text/Pandoc/Writers/Docx.hs+1−1 src/Text/Pandoc/Writers/ODT.hs+1−1 tests/Tests/Writers/Docx.hs+1−1
MANUAL.txt+37−37
@@ -794,35 +794,20 @@ Options affecting specific writers
794794: Link to a CSS style sheet. This option can be used repeatedly to
795795 include multiple files. They will be included in the order specified.
796796
797−`--reference-odt=`*FILE*
797+`--reference-doc=`*FILE*
798798
799−: Use the specified file as a style reference in producing an ODT.
800− For best results, the reference ODT should be a modified version
801− of an ODT produced using pandoc. The contents of the reference ODT
802− are ignored, but its stylesheets are used in the new ODT. If no
803− reference ODT is specified on the command line, pandoc will look
804− for a file `reference.odt` in the user data directory (see
805− `--data-dir`). If this is not found either, sensible defaults will be
806− used.
799+: Use the specified file as a style reference in producing a
800+ docx or ODT file.
807801
808− To produce a custom `reference.odt`, first get a copy of
809− the default `reference.odt`: `pandoc
810− --print-default-data-file reference.odt >
811− custom-reference.odt`. Then open `custom-reference.docx` in
812− LibreOffice, modify the styles as you wish, and save the
813− file.
814−
815−`--reference-docx=`*FILE*
816−
817−: Use the specified file as a style reference in producing a docx file.
818− For best results, the reference docx should be a modified version
819− of a docx file produced using pandoc. The contents of the reference docx
820− are ignored, but its stylesheets and document properties (including
821− margins, page size, header, and footer) are used in the new docx. If no
822− reference docx is specified on the command line, pandoc will look
823− for a file `reference.docx` in the user data directory (see
824− `--data-dir`). If this is not found either, sensible defaults will be
825− used.
802+ Docx: For best results, the reference docx should be a modified
803+ version of a docx file produced using pandoc. The contents
804+ of the reference docx are ignored, but its stylesheets and
805+ document properties (including margins, page size, header,
806+ and footer) are used in the new docx. If no reference docx
807+ is specified on the command line, pandoc will look for a
808+ file `reference.docx` in the user data directory (see
809+ `--data-dir`). If this is not found either, sensible
810+ defaults will be used.
826811
827812 To produce a custom `reference.docx`, first get a copy of
828813 the default `reference.docx`: `pandoc
@@ -830,15 +815,30 @@ Options affecting specific writers
830815 custom-reference.docx`. Then open `custom-reference.docx`
831816 in Word, modify the styles as you wish, and save the file.
832817 For best results, do not make changes to this file other
833− than modifying the styles used by pandoc: [paragraph] Normal,
834− Body Text, First Paragraph, Compact, Title, Subtitle,
835− Author, Date, Abstract, Bibliography, Heading 1, Heading 2,
836− Heading 3, Heading 4, Heading 5, Heading 6, Block Text,
837− Footnote Text, Definition Term, Definition, Caption, Table
838− Caption, Image Caption, Figure, Figure With Caption, TOC
839− Heading; [character] Default Paragraph Font, Body Text Char,
840− Verbatim Char, Footnote Reference, Hyperlink; [table] Normal
841− Table.
818+ than modifying the styles used by pandoc: [paragraph]
819+ Normal, Body Text, First Paragraph, Compact, Title,
820+ Subtitle, Author, Date, Abstract, Bibliography, Heading 1,
821+ Heading 2, Heading 3, Heading 4, Heading 5, Heading 6, Block
822+ Text, Footnote Text, Definition Term, Definition, Caption,
823+ Table Caption, Image Caption, Figure, Figure With Caption,
824+ TOC Heading; [character] Default Paragraph Font, Body Text
825+ Char, Verbatim Char, Footnote Reference, Hyperlink; [table]
826+ Normal Table.
827+
828+ ODT: For best results, the reference ODT should be a modified
829+ version of an ODT produced using pandoc. The contents of
830+ the reference ODT are ignored, but its stylesheets are used
831+ in the new ODT. If no reference ODT is specified on the
832+ command line, pandoc will look for a file `reference.odt` in
833+ the user data directory (see `--data-dir`). If this is not
834+ found either, sensible defaults will be used.
835+
836+ To produce a custom `reference.odt`, first get a copy of
837+ the default `reference.odt`: `pandoc
838+ --print-default-data-file reference.odt >
839+ custom-reference.odt`. Then open `custom-reference.docx` in
840+ LibreOffice, modify the styles as you wish, and save the
841+ file.
842842
843843`--epub-stylesheet=`*FILE*
844844
@@ -1099,7 +1099,7 @@ directory (see `--data-dir`, above). *Exceptions:*
10991099 (or the `default.beamer` template, if you use `-t beamer`,
11001100 or the `default.context` template, if you use `-t context`).
11011101- `docx` has no template (however, you can use
1102− `--reference-docx` to customize the output).
1102+ `--reference-doc` to customize the output).
11031103
11041104Templates contain *variables*, which allow for the inclusion of
11051105arbitrary information at any point in the file. Variables may be set
pandoc.hs+7−18
@@ -185,8 +185,7 @@ data Opt = Opt
185185 , optHighlightStyle :: Style -- ^ Style to use for highlighted code
186186 , optTopLevelDivision :: TopLevelDivision -- ^ Type of the top-level divisions
187187 , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
188− , optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
189− , optReferenceDocx :: Maybe FilePath -- ^ Path of reference.docx
188+ , optReferenceDoc :: Maybe FilePath -- ^ Path of reference doc
190189 , optEpubStylesheet :: Maybe String -- ^ EPUB stylesheet
191190 , optEpubMetadata :: String -- ^ EPUB metadata
192191 , optEpubFonts :: [FilePath] -- ^ EPUB fonts to embed
@@ -252,8 +251,7 @@ defaultOpts = Opt
252251 , optHighlightStyle = pygments
253252 , optTopLevelDivision = TopLevelDefault
254253 , optHTMLMathMethod = PlainMath
255− , optReferenceODT = Nothing
256− , optReferenceDocx = Nothing
254+ , optReferenceDoc = Nothing
257255 , optEpubStylesheet = Nothing
258256 , optEpubMetadata = ""
259257 , optEpubFonts = []
@@ -708,19 +706,12 @@ options =
708706 "URL")
709707 "" -- "Link to CSS style sheet"
710708
711− , Option "" ["reference-odt"]
709+ , Option "" ["reference-doc"]
712710 (ReqArg
713711 (\arg opt ->
714− return opt { optReferenceODT = Just arg })
712+ return opt { optReferenceDoc = Just arg })
715713 "FILENAME")
716− "" -- "Path of custom reference.odt"
717−
718− , Option "" ["reference-docx"]
719− (ReqArg
720− (\arg opt ->
721− return opt { optReferenceDocx = Just arg })
722− "FILENAME")
723− "" -- "Path of custom reference.docx"
714+ "" -- "Path of custom reference doc"
724715
725716 , Option "" ["epub-stylesheet"]
726717 (ReqArg
@@ -1190,8 +1181,7 @@ convertWithOpts opts args = do
11901181 , optHighlightStyle = highlightStyle
11911182 , optTopLevelDivision = topLevelDivision
11921183 , optHTMLMathMethod = mathMethod'
1193− , optReferenceODT = referenceODT
1194− , optReferenceDocx = referenceDocx
1184+ , optReferenceDoc = referenceDoc
11951185 , optEpubStylesheet = epubStylesheet
11961186 , optEpubMetadata = epubMetadata
11971187 , optEpubFonts = epubFonts
@@ -1485,8 +1475,7 @@ convertWithOpts opts args = do
14851475 writerEpubFonts = epubFonts,
14861476 writerEpubChapterLevel = epubChapterLevel,
14871477 writerTOCDepth = epubTOCDepth,
1488− writerReferenceODT = referenceODT,
1489− writerReferenceDocx = referenceDocx,
1478+ writerReferenceDoc = referenceDoc,
14901479 writerMediaBag = media,
14911480 writerVerbose = verbose,
14921481 writerLaTeXArgs = latexEngineArgs
src/Text/Pandoc/Options.hs+2−4
@@ -395,8 +395,7 @@ data WriterOptions = WriterOptions
395395 , writerEpubFonts :: [FilePath] -- ^ Paths to fonts to embed
396396 , writerEpubChapterLevel :: Int -- ^ Header level for chapters (separate files)
397397 , writerTOCDepth :: Int -- ^ Number of levels to include in TOC
398− , writerReferenceODT :: Maybe FilePath -- ^ Path to reference ODT if specified
399− , writerReferenceDocx :: Maybe FilePath -- ^ Path to reference DOCX if specified
398+ , writerReferenceDoc :: Maybe FilePath -- ^ Path to reference document if specified
400399 , writerMediaBag :: MediaBag -- ^ Media collected by docx or epub reader
401400 , writerVerbose :: Bool -- ^ Verbose debugging output
402401 , writerLaTeXArgs :: [String] -- ^ Flags to pass to latex-engine
@@ -442,8 +441,7 @@ instance Default WriterOptions where
442441 , writerEpubFonts = []
443442 , writerEpubChapterLevel = 1
444443 , writerTOCDepth = 3
445− , writerReferenceODT = Nothing
446− , writerReferenceDocx = Nothing
444+ , writerReferenceDoc = Nothing
447445 , writerMediaBag = mempty
448446 , writerVerbose = False
449447 , writerLaTeXArgs = []
src/Text/Pandoc/Writers/Docx.hs+1−1
@@ -225,7 +225,7 @@ writeDocx opts doc@(Pandoc meta _) = do
225225 username <- P.lookupEnv "USERNAME"
226226 utctime <- P.getCurrentTime
227227 distArchive <- P.getDefaultReferenceDocx datadir
228− refArchive <- case writerReferenceDocx opts of
228+ refArchive <- case writerReferenceDoc opts of
229229 Just f -> toArchive <$> P.readFileLazy f
230230 Nothing -> P.getDefaultReferenceDocx datadir
231231
src/Text/Pandoc/Writers/ODT.hs+1−1
@@ -77,7 +77,7 @@ pandocToODT opts doc@(Pandoc meta _) = do
7777 let datadir = writerUserDataDir opts
7878 let title = docTitle meta
7979 refArchive <-
80− case writerReferenceODT opts of
80+ case writerReferenceDoc opts of
8181 Just f -> liftM toArchive $ lift $ P.readFileLazy f
8282 Nothing -> lift $ P.getDefaultReferenceODT datadir
8383 -- handle formulas and pictures
tests/Tests/Writers/Docx.hs+1−1
@@ -141,7 +141,7 @@ tests = [ testGroup "inlines"
141141 ]
142142 , testGroup "customized styles"
143143 [ testCompareWithOpts
144− ( def{writerReferenceDocx=Just "docx/custom-style-reference.docx"}
144+ ( def{writerReferenceDoc=Just "docx/custom-style-reference.docx"}
145145 , def)
146146 "simple customized blocks and inlines"
147147 "docx/custom-style-roundtrip-start.native"