output directory is used. Equivalent to an
option of the same name in the
`m.math plugin <{filename}/plugins/math-and-code.rst#math>`.
+:py:`M_MATH_RENDER_AS_CODE` Don't invoke LaTex and render math as
+ inline code and code blocks. Equivalent to
+ an option of the same name in the
+ `m.math plugin <{filename}/plugins/math-and-code.rst#math>`.
:py:`M_CODE_FILTERS_PRE: Dict` Filters to apply before a code snippet is
rendered. Equivalent to an option of the
same name in the `m.code plugin <{filename}/plugins/math-and-code.rst#filters>`.
add extra CSS classes by placing ``@m_class`` in a paragraph before the actual
math block (or right before inline math), see the
`Doxygen theme-specific commands <http://localhost:8000/documentation/doxygen/#theme-specific-commands>`_
-for more information. The :ini:`M_MATH_CACHE_FILE` option is supported as well;
-there's no equivalent to the :ini:`M_MATH_RENDER_AS_CODE` option implemented at
-this point.
+for more information. The :ini:`M_MATH_CACHE_FILE` and
+:ini:`M_MATH_RENDER_AS_CODE` options are supported as well.
In addition you need some LaTeX distribution installed. Use your distribution
package manager, for example on Ubuntu:
'CLASS_INDEX_EXPAND_INNER': False,
'M_MATH_CACHE_FILE': 'm.math.cache',
+ 'M_MATH_RENDER_AS_CODE': False,
'M_CODE_FILTERS_PRE': {},
'M_CODE_FILTERS_POST': {},
logging.debug("{}: rendering math: {}".format(state.current, i.text))
- # Assume that Doxygen wrapped the formula properly to distinguish
- # between inline, block or special environment
- depth, svg = latex2svgextra.fetch_cached_or_render('{}'.format(i.text))
-
# We should have decided about block/inline above
assert formula_block is not None
- if formula_block:
- has_block_elements = True
- out.parsed += '<div class="m-math{}">{}</div>'.format(
- ' ' + add_css_class if add_css_class else '',
- latex2svgextra.patch(i.text, svg, None, ''))
+
+ # Fallback rendering as code requested
+ if state.config['M_MATH_RENDER_AS_CODE']:
+ out.parsed += '<{0} class="m-code{1}{2}">{3}</{0}>'.format(
+ 'pre' if formula_block else 'code',
+ ' ' + add_css_class if formula_block and add_css_class else '',
+ # TODO try w/ this removed
+ ' ' + add_inline_css_class if not formula_block and add_inline_css_class else '',
+ i.text)
else:
- # CSS classes and styling for proper vertical alignment. Depth is relative
- # to font size, describes how below the line the text is. Scaling it back
- # to 12pt font, scaled by 125% as set above in the config.
- attribs = ' class="m-math{}"'.format(' ' + add_inline_css_class if add_inline_css_class else '')
- out.parsed += latex2svgextra.patch(i.text, svg, depth, attribs)
+ # Assume that Doxygen wrapped the formula properly to
+ # distinguish between inline, block or special environment
+ depth, svg = latex2svgextra.fetch_cached_or_render('{}'.format(i.text))
+
+ if formula_block:
+ has_block_elements = True
+ out.parsed += '<div class="m-math{}">{}</div>'.format(
+ ' ' + add_css_class if add_css_class else '',
+ latex2svgextra.patch(i.text, svg, None, ''))
+ else:
+ # CSS classes and styling for proper vertical alignment.
+ # Depth is relative to font size, describes how below the
+ # line the text is. Scaling it back to 12pt font, scaled by
+ # 125% as set above in the config.
+ attribs = ' class="m-math{}"'.format(' ' + add_inline_css_class if add_inline_css_class else '')
+ out.parsed += latex2svgextra.patch(i.text, svg, depth, attribs)
# Inline elements
elif i.tag == 'linebreak':
('M_VERSION_LABELS', 'VERSION_LABELS', bool),
('M_MATH_CACHE_FILE', 'M_MATH_CACHE_FILE', str),
+ ('M_MATH_RENDER_AS_CODE', 'M_MATH_RENDER_AS_CODE', bool),
]:
if key not in values: continue
--- /dev/null
+INPUT = input.dox
+QUIET = YES
+GENERATE_HTML = NO
+GENERATE_LATEX = NO
+GENERATE_XML = YES
+XML_PROGRAMLISTING = NO
+CASE_SENSE_NAMES = YES
+
+##! M_PAGE_FINE_PRINT =
+##! M_THEME_COLOR =
+##! M_FAVICON =
+##! M_LINKS_NAVBAR1 =
+##! M_LINKS_NAVBAR2 =
+##! M_SEARCH_DISABLED = YES
+##! M_MATH_CACHE_FILE =
+##! M_MATH_RENDER_AS_CODE = YES
+
+ALIASES = \
+ "m_class{1}=@xmlonly<mcss:class xmlns:mcss=\"http://mcss.mosra.cz/doxygen/\" mcss:class=\"\1\" />@endxmlonly"
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>My Project</title>
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+ <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+ <div class="m-container">
+ <div class="m-row">
+ <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Project</a>
+ </div>
+ </div>
+</nav></header>
+<main><article>
+ <div class="m-container m-container-inflatable">
+ <div class="m-row">
+ <div class="m-col-l-10 m-push-l-1">
+ <h1>
+ My Project
+ </h1>
+<p>Here's a block formula:</p><pre class="m-code">\[ \hat q = [\boldsymbol 0, 1] + \epsilon [\frac{\boldsymbol v}{2}, 0] \]</pre><p>And <code class="m-code">$ \hat q $</code> is how quaternion is denoted. A green formula should have the CSS class applied:</p><pre class="m-code m-text m-success">\[ \pi^2 \]</pre><p>A yellow <code class="m-code m-text m-warning">$ \Sigma $</code> inline formula as well.</p>
+ </div>
+ </div>
+ </div>
+</article></main>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>My Project</title>
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+ <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+ <div class="m-container">
+ <div class="m-row">
+ <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Project</a>
+ </div>
+ </div>
+</nav></header>
+<main><article>
+ <div class="m-container m-container-inflatable">
+ <div class="m-row">
+ <div class="m-col-l-10 m-push-l-1">
+ <h1>
+ My Project
+ </h1>
+<p>Here's a block formula:</p><pre class="m-code">\[
+ \hat q = [\boldsymbol 0, 1] + \epsilon [\frac{\boldsymbol v}{2}, 0]
+\]</pre><p>And <code class="m-code">$ \hat q $</code> is how quaternion is denoted. A green formula should have the CSS class applied:</p><pre class="m-code m-text m-success">\[
+ \pi^2
+\]</pre><p>A yellow <code class="m-code m-text m-warning">$ \Sigma $</code> inline formula as well.</p>
+ </div>
+ </div>
+ </div>
+</article></main>
+</body>
+</html>
--- /dev/null
+/** @mainpage
+
+Here's a block formula:
+
+@f[
+ \hat q = [\boldsymbol 0, 1] + \epsilon [\frac{\boldsymbol v}{2}, 0]
+@f]
+
+And @f$ \hat q @f$ is how quaternion is denoted. A green formula should have
+the CSS class applied:
+
+@m_class{m-text m-success}
+
+@f[
+ \pi^2
+@f]
+
+A yellow @m_class{m-text m-warning} @f$ \Sigma @f$ inline formula as well.
+*/
with self.assertRaises(subprocess.CalledProcessError) as context:
self.run_doxygen(wildcard='error.xml')
+class MathCodeFallback(IntegrationTestCase):
+ def test(self):
+ self.run_doxygen(wildcard='indexpage.xml')
+
+ # Doxygen 1.9.8+ (or maybe earlier? 1.9.1 not yet) changes the spacing,
+ if parse_version(doxygen_version()) >= parse_version("1.9.8"):
+ self.assertEqual(*self.actual_expected_contents('index.html'))
+ else:
+ self.assertEqual(*self.actual_expected_contents('index.html', 'index-191.html'))
+
class MathCached(IntegrationTestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
'M_CODE_FILTERS_PRE': {},
'M_CODE_FILTERS_POST': {},
'M_MATH_CACHE_FILE': 'm.math.cache',
+ 'M_MATH_RENDER_AS_CODE': False,
'SEARCH_DISABLED': False,
'SEARCH_DOWNLOAD_BINARY': False,