chiark / gitweb /
m.math: process all math in the directive at once.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 13 Oct 2018 19:18:41 +0000 (21:18 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Oct 2018 18:17:49 +0000 (20:17 +0200)
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
pelican-plugins/m/math.py

index 69014ab5f685b0c4c1bb0483251683e796aa8d1f..04fc8ebfe9f853d7999e9fabd2e675f78ab0ef0a 100644 (file)
@@ -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::
 
index 4c446241fc69704989e8fc774dd84e66e2c04d4b..c3d8b085dfe9925015c126025a2f3f548ff1553c 100644 (file)
@@ -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