aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README14
-rw-r--r--pandoc.cabal16
-rw-r--r--src/Text/Pandoc/Templates.hs2
-rw-r--r--src/pandoc.hs11
m---------templates10
5 files changed, 32 insertions, 21 deletions
diff --git a/README b/README
index 3173075eb..a870de8ab 100644
--- a/README
+++ b/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
diff --git a/pandoc.cabal b/pandoc.cabal
index 6a67b8d2f..dc4573433 100644
--- a/pandoc.cabal
+++ b/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
diff --git a/src/Text/Pandoc/Templates.hs b/src/Text/Pandoc/Templates.hs
index cad89f35f..8b966ca7a 100644
--- a/src/Text/Pandoc/Templates.hs
+++ b/src/Text/Pandoc/Templates.hs
@@ -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)]
diff --git a/src/pandoc.hs b/src/pandoc.hs
index 5900574ce..22afd77ea 100644
--- a/src/pandoc.hs
+++ b/src/pandoc.hs
@@ -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)
diff --git a/templates b/templates
-Subproject a053c6d1b072f080bb13bc1a479ac6db7dd2b15
+Subproject 663adaa8612242dfce8c32ae5c7afc6be45c6eb