From 6992402f372f7d5df12fa4f8080af4c90dd2bb7b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 13 Oct 2018 21:18:41 +0200 Subject: [PATCH] m.math: process all math in the directive at once. Having multiple blocks is not very useful, as you don't get any of the fancy typesetting features for that. Use latex arrays for that or put the math into multiple consecutive directives. --- doc/plugins/math-and-code.rst | 2 +- pelican-plugins/m/math.py | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/doc/plugins/math-and-code.rst b/doc/plugins/math-and-code.rst index 69014ab5..04fc8ebf 100644 --- a/doc/plugins/math-and-code.rst +++ b/doc/plugins/math-and-code.rst @@ -107,7 +107,7 @@ and: Put `math blocks <{filename}/css/components.rst#math>`_ into the :rst:`.. math::` directive; if you want to color the equations, add corresponding `CSS class <{filename}/css/components.rst#colors>`_ via a :rst:`:class:` -option. Equations separated by a blank line are processed separately. +option. .. code-figure:: diff --git a/pelican-plugins/m/math.py b/pelican-plugins/m/math.py index 4c446241..c3d8b085 100644 --- a/pelican-plugins/m/math.py +++ b/pelican-plugins/m/math.py @@ -54,23 +54,18 @@ class Math(rst.Directive): pre.append(content) return [pre] - # join lines, separate blocks - content = '\n'.join(self.content).split('\n\n') - _nodes = [] - for block in content: - if not block: - continue - - _, svg = latex2svgextra.fetch_cached_or_render("$$" + block + "$$") - - container = nodes.container(**self.options) - container['classes'] += ['m-math'] - node = nodes.raw(self.block_text, latex2svgextra.patch(block, svg, None, ''), format='html') - node.line = self.content_offset + 1 - self.add_name(node) - container.append(node) - _nodes.append(container) - return _nodes + content = '\n'.join(self.content) + + _, svg = latex2svgextra.fetch_cached_or_render("$$" + content + "$$") + + node = nodes.raw(self.block_text, latex2svgextra.patch(content, svg, None, ''), format='html') + node.line = self.content_offset + 1 + self.add_name(node) + + container = nodes.container(**self.options) + container['classes'] += ['m-math'] + container.append(node) + return [container] def new_page(content): latex2svgextra.counter = 0 -- 2.30.2