git.iko.soy/typeable/pandoc
on master help sign in
Added -V/--variable option to set custom template variables.
b771051fiddlosopher
README+10−3
@@ -289,6 +289,13 @@ For further documentation, see the `pandoc(1)` man page.
289 template appropriate for the output format will be used. See also
289 template appropriate for the output format will be used. See also
290 `-D/--print-default-template`.
290 `-D/--print-default-template`.
291
291
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+
292`-c` or `--css` *filename*
299`-c` or `--css` *filename*
293: allows the user to specify a custom stylesheet that will be linked to
300: allows the user to specify a custom stylesheet that will be linked to
294 in HTML and S5 output. This option can be used repeatedly to include
301 in HTML and S5 output. This option can be used repeatedly to include
@@ -489,9 +496,9 @@ depending on the output format, but include:
489`css`
496`css`
490: links to CSS files, as specified using `-c/--css`
497: links to CSS files, as specified using `-c/--css`
491
498
492−Variables may be set at the command line using the
499+Variables may be set at the command line using the `-V/--variable`
493−`--set` option. This allows users to include custom variables in
500+option. This allows users to include custom variables in their
494−their templates.
501+templates.
495
502
496Templates may contain conditionals. The syntax is as follows:
503Templates may contain conditionals. The syntax is as follows:
497
504
man/man1/markdown2pdf.1.md+7
@@ -54,6 +54,13 @@ The following options are most relevant:
54 `-s`. See the section TEMPLATES in `pandoc`(1) for information about
54 `-s`. See the section TEMPLATES in `pandoc`(1) for information about
55 template syntax.
55 template syntax.
56
56
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+
57-H *FILE*, \--include-in-header=*FILE*
64-H *FILE*, \--include-in-header=*FILE*
58: Include (LaTeX) contents of *FILE* at the end of the header. Implies
65: Include (LaTeX) contents of *FILE* at the end of the header. Implies
59 `-s`.
66 `-s`.
man/man1/pandoc.1.md+10−3
@@ -175,6 +175,13 @@ to Pandoc. Or use `html2markdown`(1), a wrapper around `pandoc`.
175 this option is not used, a default template appropriate for the
175 this option is not used, a default template appropriate for the
176 output format will be used. See also `-D/--print-default-template`.
176 output format will be used. See also `-D/--print-default-template`.
177
177
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+
178-c *CSS*, \--css=*CSS*
185-c *CSS*, \--css=*CSS*
179: Link to a CSS style sheet. *CSS* is the pathname of the style sheet.
186: Link to a CSS style sheet. *CSS* is the pathname of the style sheet.
180
187
@@ -270,9 +277,9 @@ depending on the output format, but include:
270`css`
277`css`
271: links to CSS files, as specified using `-c/--css`
278: links to CSS files, as specified using `-c/--css`
272
279
273−Variables may be set at the command line using the
280+Variables may be set at the command line using the `-V/--variable`
274−`--set` option. This allows users to include custom variables in
281+option. This allows users to include custom variables in their
275−their templates.
282+templates.
276
283
277Templates may contain conditionals. The syntax is as follows:
284Templates may contain conditionals. The syntax is as follows:
278
285
src/markdown2pdf.hs+3−2
@@ -152,13 +152,14 @@ main = bracket
152 unless (null miss) $ exit $! "Could not find " ++ intercalate ", " miss
152 unless (null miss) $ exit $! "Could not find " ++ intercalate ", " miss
153 args <- getArgs
153 args <- getArgs
154 -- check for invalid arguments and print help message if needed
154 -- 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"]
156 let goodoptslong = ["--from","--read","--strict",
156 let goodoptslong = ["--from","--read","--strict",
157 "--preserve-tabs","--tab-stop","--parse-raw",
157 "--preserve-tabs","--tab-stop","--parse-raw",
158 "--toc","--table-of-contents",
158 "--toc","--table-of-contents",
159 "--number-sections","--include-in-header",
159 "--number-sections","--include-in-header",
160 "--include-before-body","--include-after-body",
160 "--include-before-body","--include-after-body",
161− "--custom-header","--output"]
161+ "--custom-header","--output",
162+ "--template", "--variable"]
162 let isOpt ('-':_) = True
163 let isOpt ('-':_) = True
163 isOpt _ = False
164 isOpt _ = False
164 let opts = filter isOpt args
165 let opts = filter isOpt args
src/pandoc.hs+13
@@ -339,6 +339,19 @@ options =
339 "FILENAME")
339 "FILENAME")
340 "" -- "Use custom template"
340 "" -- "Use custom template"
341
341
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+
342 , Option "c" ["css"]
355 , Option "c" ["css"]
343 (ReqArg
356 (ReqArg
344 (\arg opt -> do
357 (\arg opt -> do