antonio
antonio

Reputation: 11120

Pandoc HTML variables: `quotes` and `math`

Pandoc default HTML template contains these two variables:

How are they supposed to be used?

More specifically I see that quotes sets the values for the tag <q>. Is this tag used in markdown to HTML conversion?

Upvotes: 1

Views: 889

Answers (2)

scoa
scoa

Reputation: 19867

tl;dr: they seem to be mostly obsolete legacies from previous versions of pandoc

quotes

A little archeology of pandoc commits shows that 'quotes' was added when pandoc switched from using <q> tags to directly adding quotes signs. A new option, --html-q-tags was added to keep the previous behavior: the option wraps quotes in <q> and sets quotes to true so that a piece of css code is added as explained in the html template. See this commit to pandoc and this commit to pandoc-templates. See the behavior with the following file:

"hello world"

This:

pandoc test.md -t html --smart --standalone

Produces (skipping the usual head, with no css affecting <q>)

<p>“hello world”</p>

While this

pandoc test.md -t html --standalone --html-q-tags --smart

produces (skipping the usual header)

  <style type="text/css">q { quotes: "“" "”" "‘" "’"; }</style>
</head>
<body>
<p><q>hello world</q></p>
</body>

You have to use --smart though.

math

It looks like this was introduced to include math rendering scripts inside the standalone file. See this commit from 2010. I think some command-line options picking non-(currently)-default math rendering systems, like --mathml, sets this variable to a value that actually makes sense (like copying the math rendering scripts). Try:

pandoc -t html --mathml

Upvotes: 1

antonio
antonio

Reputation: 11120

For the quotes variable, see @scoa.
As regards the math variable, I found what follows.

When using MathML, that is the option --mathml, the code block:

$if(math)$
  $math$
$endif$

in the default HTML conversion template adds a portability script to the HTML output. Anyway, Chrome and Edge do not currently support MathML and Firefox seems to support it without this script. So, for a custom template, removing the $if(math)$ ... code block will not affect MathML rendering.

When using MathJax, that is the option --mathjax, $if(math)$ ... adds to the HTML output the script block:

<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML-full" type="text/javascript"></script>

This is always necessary to render the maths formulae.

When using the --latexmathml, a giant script, converting the LaTeX style math into MathML, is inserted by the $if(math)$ ... code block. Without this code block in the conversion template, the script is not inserted and the maths can't be rendered.

Upvotes: 0

Related Questions