Added --reference-odt option.
This allows the user to customized the styles used in pandoc-generated ODTs. The user may also put a default reference.odt in the ~/.pandoc directory. We have removed the old data/odt directory and replaced it with a reference.odt. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1760 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
bdd448ea2c
commit
ed1535de10
12 changed files with 52 additions and 1110 deletions
11
README
11
README
|
@ -324,6 +324,17 @@ For further documentation, see the `pandoc(1)` man page.
|
|||
repeatedly to include multiple files. They will be included in the
|
||||
order specified.
|
||||
|
||||
`--reference-odt` *filename*
|
||||
: uses the specified file as a style reference in producing an ODT.
|
||||
For best results, the reference ODT should be a modified version
|
||||
of an ODT produced using pandoc. The contents of the reference ODT
|
||||
are ignored, but its stylesheets are used in the new ODT. If no
|
||||
reference ODT is specified on the command line, pandoc will look
|
||||
for `$HOME/.pandoc/reference.odt` (on unix) or
|
||||
`C:\Documents And Settings\USERNAME\Application Data\pandoc\reference.odt`
|
||||
(on Windows). If this is not found either, sensible defaults will be
|
||||
used.
|
||||
|
||||
`-D` or `--print-default-template` *format*
|
||||
: prints the default template for an output *format*. (See `-t`
|
||||
for a list of possible *format*s.)
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
|
||||
<manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.text" manifest:full-path="/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/statusbar/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/accelerator/current.xml"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/accelerator/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/floater/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/popupmenu/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/progressbar/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/menubar/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/toolbar/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/images/Bitmaps/"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Configurations2/images/"/>
|
||||
<manifest:file-entry manifest:media-type="application/vnd.sun.xml.ui.configuration" manifest:full-path="Configurations2/"/>
|
||||
<manifest:file-entry manifest:media-type="application/binary" manifest:full-path="layout-cache"/>
|
||||
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
|
||||
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="styles.xml"/>
|
||||
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="meta.xml"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Thumbnails/thumbnail.png"/>
|
||||
<manifest:file-entry manifest:media-type="" manifest:full-path="Thumbnails/"/>
|
||||
<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="settings.xml"/>
|
||||
</manifest:manifest>
|
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB |
|
@ -1 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><office:document-meta xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:ooo="http://openoffice.org/2004/office" office:version="1.1"><office:meta><meta:generator></meta:generator><dc:title></dc:title><dc:subject></dc:subject><meta:creation-date></meta:creation-date><dc:date></dc:date><meta:editing-cycles></meta:editing-cycles><meta:editing-duration></meta:editing-duration><meta:user-defined meta:name="Info 1"/><meta:user-defined meta:name="Info 2"/><meta:user-defined meta:name="Info 3"/><meta:user-defined meta:name="Info 4"/><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="0" meta:paragraph-count="0" meta:word-count="0" meta:character-count="0"/></office:meta></office:document-meta>
|
|
@ -1 +0,0 @@
|
|||
application/vnd.oasis.opendocument.text
|
File diff suppressed because one or more lines are too long
1062
data/odt/styles.xml
1062
data/odt/styles.xml
File diff suppressed because it is too large
Load diff
|
@ -203,6 +203,17 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
|
|||
Implies `-s`. Note: This option is deprecated. Users should
|
||||
transition to using `--template` instead.
|
||||
|
||||
\--reference-odt=*filename*
|
||||
: Use the specified file as a style reference in producing an ODT.
|
||||
For best results, the reference ODT should be a modified version
|
||||
of an ODT produced using pandoc. The contents of the reference ODT
|
||||
are ignored, but its stylesheets are used in the new ODT. If no
|
||||
reference ODT is specified on the command line, pandoc will look
|
||||
for `$HOME/.pandoc/reference.odt` (on unix) or
|
||||
`C:\Documents And Settings\USERNAME\Application Data\pandoc\reference.odt`
|
||||
(on Windows). If this is not found either, sensible defaults will be
|
||||
used.
|
||||
|
||||
-D *FORMAT*, \--print-default-template=*FORMAT*
|
||||
: Print the default template for an output *FORMAT*. (See `-t`
|
||||
for a list of possible *FORMAT*s.)
|
||||
|
|
|
@ -43,12 +43,7 @@ Data-Files:
|
|||
templates/rst.template,
|
||||
templates/mediawiki.template, templates/rtf.template,
|
||||
-- data for ODT writer
|
||||
data/odt/meta.xml,
|
||||
data/odt/settings.xml,
|
||||
data/odt/META-INF/manifest.xml,
|
||||
data/odt/Thumbnails/thumbnail.png,
|
||||
data/odt/styles.xml,
|
||||
data/odt/mimetype,
|
||||
reference.odt,
|
||||
-- data for LaTeXMathML writer
|
||||
data/LaTeXMathML.js.comment,
|
||||
data/LaTeXMathML.js.packed,
|
||||
|
@ -151,7 +146,7 @@ Library
|
|||
parsec >= 2.1 && < 3, xhtml >= 3000.0,
|
||||
mtl >= 1.1, network >= 2, filepath >= 1.1,
|
||||
process >= 1, directory >= 1, template-haskell >= 2.2,
|
||||
bytestring >= 0.9, zip-archive >= 0.1.1,
|
||||
bytestring >= 0.9, zip-archive >= 0.1.1.4,
|
||||
utf8-string >= 0.3, old-time >= 1
|
||||
if impl(ghc >= 6.10)
|
||||
Build-depends: base >= 4 && < 5, syb
|
||||
|
|
BIN
reference.odt
Normal file
BIN
reference.odt
Normal file
Binary file not shown.
|
@ -37,24 +37,27 @@ import Codec.Archive.Zip
|
|||
import Control.Applicative ( (<$>) )
|
||||
import Text.ParserCombinators.Parsec
|
||||
import System.Time
|
||||
import Text.Pandoc.Shared ( inDirectory )
|
||||
import Paths_pandoc ( getDataFileName )
|
||||
import System.Directory
|
||||
import Control.Monad (liftM)
|
||||
|
||||
-- | Produce an ODT file from OpenDocument XML.
|
||||
saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
|
||||
-> FilePath -- ^ Relative directory of source file.
|
||||
-> String -- ^ OpenDocument XML contents.
|
||||
saveOpenDocumentAsODT :: FilePath -- ^ Pathname of ODT file to be produced.
|
||||
-> FilePath -- ^ Relative directory of source file.
|
||||
-> Maybe FilePath -- ^ Path specified by --reference-odt
|
||||
-> String -- ^ OpenDocument XML contents.
|
||||
-> IO ()
|
||||
saveOpenDocumentAsODT destinationODTPath sourceDirRelative xml = do
|
||||
userDir <- getAppUserDataDirectory "pandoc"
|
||||
userOdtExists <- doesFileExist $
|
||||
userDir </> "data" </> "odt" </> "styles.xml"
|
||||
refArchivePath <- if userOdtExists
|
||||
then return $ userDir </> "data" </> "odt"
|
||||
else getDataFileName $ "data" </> "odt"
|
||||
refArchive <- inDirectory refArchivePath $
|
||||
addFilesToArchive [OptRecursive] emptyArchive ["."]
|
||||
saveOpenDocumentAsODT destinationODTPath sourceDirRelative mbRefOdt xml = do
|
||||
refArchive <- liftM toArchive $
|
||||
case mbRefOdt of
|
||||
Just f -> B.readFile f
|
||||
Nothing -> do
|
||||
userDataDir <- getAppUserDataDirectory "pandoc"
|
||||
let userRefOdt = userDataDir </> "reference.odt"
|
||||
userRefOdtExists <- doesFileExist userRefOdt
|
||||
if userRefOdtExists
|
||||
then B.readFile userRefOdt
|
||||
else getDataFileName "reference.odt" >>= B.readFile
|
||||
-- handle pictures
|
||||
let (newContents, pics) =
|
||||
case runParser pPictures [] "OpenDocument XML contents" xml of
|
||||
|
|
|
@ -151,6 +151,7 @@ data Opt = Opt
|
|||
, optXeTeX :: Bool -- ^ Format latex for xetex
|
||||
, optSmart :: Bool -- ^ Use smart typography
|
||||
, optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math
|
||||
, optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt
|
||||
, optDumpArgs :: Bool -- ^ Output command-line arguments
|
||||
, optIgnoreArgs :: Bool -- ^ Ignore command-line arguments
|
||||
, optStrict :: Bool -- ^ Use strict markdown syntax
|
||||
|
@ -188,6 +189,7 @@ defaultOpts = Opt
|
|||
, optXeTeX = False
|
||||
, optSmart = False
|
||||
, optHTMLMathMethod = PlainMath
|
||||
, optReferenceODT = Nothing
|
||||
, optDumpArgs = False
|
||||
, optIgnoreArgs = False
|
||||
, optStrict = False
|
||||
|
@ -429,6 +431,13 @@ options =
|
|||
"STRING")
|
||||
"" -- "String to prefix to HTML window title"
|
||||
|
||||
, Option "" ["reference-odt"]
|
||||
(ReqArg
|
||||
(\arg opt -> do
|
||||
return opt { optReferenceODT = Just arg })
|
||||
"FILENAME")
|
||||
"" -- "Path of custom reference.odt"
|
||||
|
||||
, Option "D" ["print-default-template"]
|
||||
(ReqArg
|
||||
(\arg _ -> do
|
||||
|
@ -582,6 +591,7 @@ main = do
|
|||
, optXeTeX = xetex
|
||||
, optSmart = smart
|
||||
, optHTMLMathMethod = mathMethod
|
||||
, optReferenceODT = referenceODT
|
||||
, optDumpArgs = dumpArgs
|
||||
, optIgnoreArgs = ignoreArgs
|
||||
, optStrict = strict
|
||||
|
@ -717,9 +727,9 @@ main = do
|
|||
#endif
|
||||
|
||||
let writerOutput = writer writerOptions doc' ++ "\n"
|
||||
|
||||
|
||||
case writerName' of
|
||||
"odt" -> saveOpenDocumentAsODT outputFile sourceDirRelative writerOutput
|
||||
"odt" -> saveOpenDocumentAsODT outputFile sourceDirRelative referenceODT writerOutput
|
||||
_ -> if outputFile == "-"
|
||||
then putStr writerOutput
|
||||
else writeFile outputFile writerOutput
|
||||
|
|
Loading…
Reference in a new issue