From: lollipopman Date: Tue, 21 Jun 2016 14:04:08 +0000 (+0000) Subject: Add pandoc_html_extra_options X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=f9e295e540fffc97d965dc942de65f1e3f9531ee;p=ikiwiki-pandoc.git Add pandoc_html_extra_options This allows you to add other options to pandoc when exporting html. Useful when adding '--toc' or other pandoc options. --- diff --git a/README.md b/README.md index 88f5b0e..9d7dd5a 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,8 @@ These settings have no effect unless you have activated the `page.tmpl` file whi * `pandoc_codeclasses` (string): CSS classes to add to indented code blocks. One may also specify CSS classes individually for each block. +* `pandoc_html_extra_options`: List of extra pandoc options for HTML output. (Note that this, like other `*_extra_options`, is a *list*, not simply a string). You may also set this option per page in the yaml metadata block with `html_extra_options`, setting it on an individual page overrides the global setting, even if the per page setting is an empty list. + ### Extra output formats It is sometimes useful to use pandoc to export the content of a wiki page to non-html formats, e.g. pdf or docx. This can be triggered by setting certain attributes in the YAML meta block of the page. The currently supported formats are `pdf`, `docx`, `odt`, `latex`, `beamer`, `revealjs` and `epub`. The corresponding meta attributes are the boolean values `generate_pdf`, `generate_docx`, `generate_odt`, `generate_latex`, `generate_beamer`, `generate_revealjs` and `generate_epub`. As a shortcut, `generate_all_formats` will turn on the generation of all seven formats; some of them may then be turned off individually. For instance, diff --git a/pandoc.pm b/pandoc.pm index a3b803a..5fe2d0a 100755 --- a/pandoc.pm +++ b/pandoc.pm @@ -166,6 +166,13 @@ sub getsetup () { safe => 1, rebuild => 1, }, + pandoc_html_extra_options => { + type => "internal", + default => [], + description => "List of extra pandoc options for html", + safe => 0, + rebuild => 0, + }, pandoc_numsect => { type => "boolean", example => 0, @@ -534,10 +541,24 @@ sub htmlize ($@) { } } + # html_extra_options my be set in Meta block in the page or in the .setup + # file. If both are present, the Meta block has precedence, even if it is + # an empty list + my @html_args = @args; + if (ref $meta->{html_extra_options}{c} eq 'ARRAY') { + if (ref unwrap_c($meta->{html_extra_options}{c}) eq 'ARRAY') { + push @html_args, @{unwrap_c($meta->{html_extra_options}{c})}; + } else { + push @html_args, unwrap_c($meta->{html_extra_options}{c}); + } + } elsif (ref $config{'pandoc_html_extra_options'} eq 'ARRAY') { + push @html_args, @{$config{'pandoc_html_extra_options'}}; + } + my $to_html_pid = open2(*PANDOC_IN, *JSON_IN, $command, '-f', 'json', '-t', $htmlformat, - @args); + @html_args); error("Unable to open $command") unless $to_html_pid; $pagestate{$page}{pandoc_extra_formats} = {};