git.iko.soy/typeable/pandoc
on master help sign in
Added -V/--variable option to set custom template variables.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1685 788f1e2b-df1e-0410-8736-df70ead52e1b

commitb771051432be70015079ad7e5cb36afa6b6939bf authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:10 (17 years ago) parent9f126c1
5 files changed+43−8
README+10−3 man/man1/markdown2pdf.1.md+7 man/man1/pandoc.1.md+10−3 src/markdown2pdf.hs+3−2 src/pandoc.hs+13
README+10−3
@@ -289,6 +289,13 @@ For further documentation, see the `pandoc(1)` man page.
289289 template appropriate for the output format will be used. See also
290290 `-D/--print-default-template`.
291291
292+`-V` *key=val*, `--variable=`*key:val*
293+: sets the template variable *key* to the value *val* when rendering the
294+ document in standalone mode. This is only useful when the
295+ `--template` option is used to specify a custom template, since
296+ pandoc automatically sets the variables used in the default
297+ templates.
298+
292299`-c` or `--css` *filename*
293300: allows the user to specify a custom stylesheet that will be linked to
294301 in HTML and S5 output. This option can be used repeatedly to include
@@ -489,9 +496,9 @@ depending on the output format, but include:
489496`css`
490497: links to CSS files, as specified using `-c/--css`
491498
492−Variables may be set at the command line using the
493−`--set` option. This allows users to include custom variables in
494−their templates.
499+Variables may be set at the command line using the `-V/--variable`
500+option. This allows users to include custom variables in their
501+templates.
495502
496503Templates may contain conditionals. The syntax is as follows:
497504
man/man1/markdown2pdf.1.md+7
@@ -54,6 +54,13 @@ The following options are most relevant:
5454 `-s`. See the section TEMPLATES in `pandoc`(1) for information about
5555 template syntax.
5656
57+-V KEY=VAL, \--variable=*KEY:VAL*
58+: Set the template variable KEY to the value VAL when rendering the
59+ document in standalone mode. This is only useful when the
60+ `--template` option is used to specify a custom template, since
61+ pandoc automatically sets the variables used in the default
62+ templates.
63+
5764-H *FILE*, \--include-in-header=*FILE*
5865: Include (LaTeX) contents of *FILE* at the end of the header. Implies
5966 `-s`.
man/man1/pandoc.1.md+10−3
@@ -175,6 +175,13 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
175175 this option is not used, a default template appropriate for the
176176 output format will be used. See also `-D/--print-default-template`.
177177
178+-V KEY=VAL, \--variable=*KEY:VAL*
179+: Set the template variable KEY to the value VAL when rendering the
180+ document in standalone mode. This is only useful when the
181+ `--template` option is used to specify a custom template, since
182+ pandoc automatically sets the variables used in the default
183+ templates.
184+
178185-c *CSS*, \--css=*CSS*
179186: Link to a CSS style sheet. *CSS* is the pathname of the style sheet.
180187
@@ -270,9 +277,9 @@ depending on the output format, but include:
270277`css`
271278: links to CSS files, as specified using `-c/--css`
272279
273−Variables may be set at the command line using the
274−`--set` option. This allows users to include custom variables in
275−their templates.
280+Variables may be set at the command line using the `-V/--variable`
281+option. This allows users to include custom variables in their
282+templates.
276283
277284Templates may contain conditionals. The syntax is as follows:
278285
src/markdown2pdf.hs+3−2
@@ -152,13 +152,14 @@ main = bracket
152152 unless (null miss) $ exit $! "Could not find " ++ intercalate ", " miss
153153 args <- getArgs
154154 -- check for invalid arguments and print help message if needed
155− let goodopts = ["-f","-r","-N", "-p","-R","-H","-B","-A", "-C","-o"]
155+ let goodopts = ["-f","-r","-N", "-p","-R","-H","-B","-A", "-C","-o","-V"]
156156 let goodoptslong = ["--from","--read","--strict",
157157 "--preserve-tabs","--tab-stop","--parse-raw",
158158 "--toc","--table-of-contents",
159159 "--number-sections","--include-in-header",
160160 "--include-before-body","--include-after-body",
161− "--custom-header","--output"]
161+ "--custom-header","--output",
162+ "--template", "--variable"]
162163 let isOpt ('-':_) = True
163164 isOpt _ = False
164165 let opts = filter isOpt args
src/pandoc.hs+13
@@ -339,6 +339,19 @@ options =
339339 "FILENAME")
340340 "" -- "Use custom template"
341341
342+ , Option "V" ["variable"]
343+ (ReqArg
344+ (\arg opt ->
345+ case break (`elem` ":=") arg of
346+ (k,_:v) -> do
347+ let newvars = (k, v) : optVariables opt
348+ return opt{ optVariables = newvars }
349+ _ -> do
350+ hPutStrLn stderr $ "Could not parse `" ++ arg ++ "' as a key/value pair (k=v or k:v)"
351+ exitWith $ ExitFailure 17)
352+ "FILENAME")
353+ "" -- "Use custom template"
354+
342355 , Option "c" ["css"]
343356 (ReqArg
344357 (\arg opt -> do