git.iko.soy/typeable/pandoc
on master help sign in
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`.

commitfd34dcba851ad1567b8969676174fc03a3afb958 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 22 Jul 2011, 22:49 (15 years ago) parent9440512
5 files changed+28−17
README+9−5 pandoc.cabal+8−8 src/Text/Pandoc/Templates.hs+1−1 src/pandoc.hs+9−2 templates+1−1
README+9−5
@@ -324,13 +324,17 @@ Options
324324`--template=`*FILE*
325325: Use *FILE* as a custom template for the generated document. Implies
326326 `--standalone`. See [Templates](#templates) below for a description
327− of template syntax. If this option is not used, a default
328− template appropriate for the output format will be used. See also
329− `-D/--print-default-template`.
327+ of template syntax. If no extension is specified, an extension
328+ corresponding to the writer will be added, so that `--template=special`
329+ looks for `special.html` for HTML output. If the template is not
330+ found, pandoc will search for it in the user data directory
331+ (see `--data-dir`). If this option is not used, a default
332+ template appropriate for the output format will be used (see
333+ `-D/--print-default-template`).
330334
331335`-V` *KEY=VAL*, `--variable=`*KEY:VAL*
332336: Set the template variable *KEY* to the value *VAL* when rendering the
333− document in standalone mode. This is only useful when the
337+ document in standalone mode. This is generally only useful when the
334338 `--template` option is used to specify a custom template, since
335339 pandoc automatically sets the variables used in the default
336340 templates.
@@ -498,7 +502,7 @@ document. To see the default template that is used, just type
498502where `FORMAT` is the name of the output format. A custom template
499503can be specified using the `--template` option. You can also override
500504the system default templates for a given output format `FORMAT`
501−by putting a file `templates/FORMAT.template` in the user data
505+by putting a file `templates/default.FORMAT` in the user data
502506directory (see `--data-dir`, above).
503507
504508Templates may contain *variables*. Variable names are sequences of
pandoc.cabal+8−8
@@ -37,14 +37,14 @@ Description: Pandoc is a Haskell library for converting from one markup
3737 only adding a reader or writer.
3838Data-Files:
3939 -- templates
40− templates/html.template, templates/docbook.template,
41− templates/opendocument.template, templates/latex.template,
42− templates/context.template, templates/texinfo.template,
43− templates/man.template, templates/markdown.template,
44− templates/rst.template, templates/plain.template,
45− templates/mediawiki.template, templates/rtf.template,
46− templates/s5.template, templates/slidy.template,
47− templates/textile.template, templates/org.template
40+ templates/default.html, templates/default.docbook,
41+ templates/default.opendocument, templates/default.latex,
42+ templates/default.context, templates/default.texinfo,
43+ templates/default.man, templates/default.markdown,
44+ templates/default.rst, templates/default.plain,
45+ templates/default.mediawiki, templates/default.rtf,
46+ templates/default.s5, templates/default.slidy,
47+ templates/default.textile, templates/default.org
4848 -- data for ODT writer
4949 reference.odt,
5050 -- stylesheet for EPUB writer
src/Text/Pandoc/Templates.hs+1−1
@@ -85,7 +85,7 @@ getDefaultTemplate _ "native" = return $ Right ""
8585getDefaultTemplate user "odt" = getDefaultTemplate user "opendocument"
8686getDefaultTemplate user writer = do
8787 let format = takeWhile (/='+') writer -- strip off "+lhs" if present
88− let fname = "templates" </> format <.> "template"
88+ let fname = "templates" </> "default" <.> format
8989 E.try $ readDataFile user fname
9090
9191data TemplateState = TemplateState Int [(String,String)]
src/pandoc.hs+9−2
@@ -738,10 +738,17 @@ main = do
738738 case deftemp of
739739 Left e -> throwIO e
740740 Right t -> return t
741− Just tp -> catch (UTF8.readFile tp)
741+ Just tp -> do
742+ -- strip off "+lhs" if present
743+ let format = takeWhile (/='+') writerName'
744+ let tp' = case takeExtension tp of
745+ "" -> tp <.> format
746+ _ -> tp
747+ catch (UTF8.readFile tp')
742748 (\e -> if isDoesNotExistError e
743749 then catch
744− (readDataFile datadir tp)
750+ (readDataFile datadir $
751+ "templates" </> tp')
745752 (\_ -> throwIO e)
746753 else throwIO e)
747754
templates+1−1

Submodule changed.