Changed default template naming scheme.
Instead of latex.template, we now have default.latex. An appropriate extension is added automatically if the value of `--template` has no extension. So, `pandoc --template=special -t latex` looks for `special.latex`, while `pandoc --template=special -t man` looks for `special.man`.
This commit is contained in:
parent
94405121ab
commit
fd34dcba85
5 changed files with 28 additions and 17 deletions
14
README
14
README
|
@ -324,13 +324,17 @@ Options
|
|||
`--template=`*FILE*
|
||||
: Use *FILE* as a custom template for the generated document. Implies
|
||||
`--standalone`. See [Templates](#templates) below for a description
|
||||
of template syntax. If this option is not used, a default
|
||||
template appropriate for the output format will be used. See also
|
||||
`-D/--print-default-template`.
|
||||
of template syntax. If no extension is specified, an extension
|
||||
corresponding to the writer will be added, so that `--template=special`
|
||||
looks for `special.html` for HTML output. If the template is not
|
||||
found, pandoc will search for it in the user data directory
|
||||
(see `--data-dir`). If this option is not used, a default
|
||||
template appropriate for the output format will be used (see
|
||||
`-D/--print-default-template`).
|
||||
|
||||
`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
|
||||
: Set the template variable *KEY* to the value *VAL* when rendering the
|
||||
document in standalone mode. This is only useful when the
|
||||
document in standalone mode. This is generally only useful when the
|
||||
`--template` option is used to specify a custom template, since
|
||||
pandoc automatically sets the variables used in the default
|
||||
templates.
|
||||
|
@ -498,7 +502,7 @@ document. To see the default template that is used, just type
|
|||
where `FORMAT` is the name of the output format. A custom template
|
||||
can be specified using the `--template` option. You can also override
|
||||
the system default templates for a given output format `FORMAT`
|
||||
by putting a file `templates/FORMAT.template` in the user data
|
||||
by putting a file `templates/default.FORMAT` in the user data
|
||||
directory (see `--data-dir`, above).
|
||||
|
||||
Templates may contain *variables*. Variable names are sequences of
|
||||
|
|
16
pandoc.cabal
16
pandoc.cabal
|
@ -37,14 +37,14 @@ Description: Pandoc is a Haskell library for converting from one markup
|
|||
only adding a reader or writer.
|
||||
Data-Files:
|
||||
-- templates
|
||||
templates/html.template, templates/docbook.template,
|
||||
templates/opendocument.template, templates/latex.template,
|
||||
templates/context.template, templates/texinfo.template,
|
||||
templates/man.template, templates/markdown.template,
|
||||
templates/rst.template, templates/plain.template,
|
||||
templates/mediawiki.template, templates/rtf.template,
|
||||
templates/s5.template, templates/slidy.template,
|
||||
templates/textile.template, templates/org.template
|
||||
templates/default.html, templates/default.docbook,
|
||||
templates/default.opendocument, templates/default.latex,
|
||||
templates/default.context, templates/default.texinfo,
|
||||
templates/default.man, templates/default.markdown,
|
||||
templates/default.rst, templates/default.plain,
|
||||
templates/default.mediawiki, templates/default.rtf,
|
||||
templates/default.s5, templates/default.slidy,
|
||||
templates/default.textile, templates/default.org
|
||||
-- data for ODT writer
|
||||
reference.odt,
|
||||
-- stylesheet for EPUB writer
|
||||
|
|
|
@ -85,7 +85,7 @@ getDefaultTemplate _ "native" = return $ Right ""
|
|||
getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument"
|
||||
getDefaultTemplate user writer = do
|
||||
let format = takeWhile (/='+') writer -- strip off "+lhs" if present
|
||||
let fname = "templates" </> format <.> "template"
|
||||
let fname = "templates" </> "default" <.> format
|
||||
E.try $ readDataFile user fname
|
||||
|
||||
data TemplateState = TemplateState Int [(String,String)]
|
||||
|
|
|
@ -738,10 +738,17 @@ main = do
|
|||
case deftemp of
|
||||
Left e -> throwIO e
|
||||
Right t -> return t
|
||||
Just tp -> catch (UTF8.readFile tp)
|
||||
Just tp -> do
|
||||
-- strip off "+lhs" if present
|
||||
let format = takeWhile (/='+') writerName'
|
||||
let tp' = case takeExtension tp of
|
||||
"" -> tp <.> format
|
||||
_ -> tp
|
||||
catch (UTF8.readFile tp')
|
||||
(\e -> if isDoesNotExistError e
|
||||
then catch
|
||||
(readDataFile datadir tp)
|
||||
(readDataFile datadir $
|
||||
"templates" </> tp')
|
||||
(\_ -> throwIO e)
|
||||
else throwIO e)
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a053c6d1b072f080bb13bc1a479ac6db7dd2b154
|
||||
Subproject commit 663adaa8612242dfce8c32ae5c7afc6be45c6eb6
|
Loading…
Add table
Reference in a new issue