chiark / gitweb /
m.math: compatibility with math figures from m.components.
authorVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Oct 2018 14:38:38 +0000 (16:38 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 14 Oct 2018 18:17:49 +0000 (20:17 +0200)
doc/plugins/math-and-code.rst
pelican-plugins/m/math.py
pelican-plugins/m/test/dot/page.rst
pelican-plugins/m/test/math/page-code-fallback.html
pelican-plugins/m/test/math/page.html
pelican-plugins/m/test/math/page.rst
pelican-plugins/m/test/test_math.py

index 04fc8ebfe9f853d7999e9fabd2e675f78ab0ef0a..58ac70a9da0cac6adeadee7d7df7a134e52b935e 100644 (file)
@@ -219,6 +219,47 @@ to disable caching.
             logging.warning("LaTeX not found, fallback to rendering math as code")
             M_MATH_RENDER_AS_CODE = True
 
+`Math figure`_
+--------------
+
+See the `m.components <{filename}/plugins/components.rst#code-math-and-graph-figure>`__
+plugin for details about code figures using the :rst:`.. math-figure::`
+directive.
+
+.. code-figure::
+
+    .. code:: rst
+
+        .. math-figure:: Infinite projection matrix
+
+            .. math::
+                :class: m-success
+
+                \boldsymbol{A} = \begin{pmatrix}
+                    \frac{2n}{s_x} & 0 & 0 & 0 \\
+                    0 & \frac{2n}{s_y} & 0 & 0 \\
+                    0 & 0 & -1 & -2n \\
+                    0 & 0 & -1 & 0
+                \end{pmatrix}
+
+            With :math:`f = \infty`.
+
+    .. math-figure:: Infinite projection matrix
+
+        .. math::
+            :class: m-success
+
+            \boldsymbol{A} = \begin{pmatrix}
+                \frac{2n}{s_x} & 0 & 0 & 0 \\
+                0 & \frac{2n}{s_y} & 0 & 0 \\
+                0 & 0 & -1 & -2n \\
+                0 & 0 & -1 & 0
+            \end{pmatrix}
+
+        .. class:: m-noindent
+
+        With :math:`f = \infty`.
+
 `Code`_
 =======
 
index c3d8b085dfe9925015c126025a2f3f548ff1553c..c32e2e805d5a980ce03e7974969fe51d44002d9e 100644 (file)
@@ -38,6 +38,17 @@ import latex2svgextra
 
 render_as_code = False
 
+def _is_math_figure(parent):
+    # The parent has to be a figure, marked as m-figure
+    if not isinstance(parent, nodes.figure): return False
+    if 'm-figure' not in parent.get('classes', []): return False
+
+    # And as a first visible node of such type
+    for child in parent:
+        if not isinstance(child, nodes.Invisible): return False
+
+    return True
+
 class Math(rst.Directive):
     option_spec = {'class': directives.class_option,
                    'name': directives.unchanged}
@@ -47,8 +58,15 @@ class Math(rst.Directive):
         set_classes(self.options)
         self.assert_has_content()
 
+        parent = self.state.parent
+
         # Fallback rendering as code requested
         if render_as_code:
+            # If this is a math figure, replace the figure CSS class to have a
+            # matching border
+            if _is_math_figure(parent):
+                parent['classes'][parent['classes'].index('m-figure')] = 'm-code-figure'
+
             content = nodes.raw('', html.escape('\n'.join(self.content)), format='html')
             pre = nodes.literal_block('')
             pre.append(content)
@@ -58,10 +76,18 @@ class Math(rst.Directive):
 
         _, svg = latex2svgextra.fetch_cached_or_render("$$" + content + "$$")
 
+        # If this is the first real node inside a math figure, put the SVG
+        # directly inside
+        if _is_math_figure(parent):
+            node = nodes.raw(self.block_text, latex2svgextra.patch(content, svg, None, ' class="{}"'.format(' '.join(['m-math'] + self.options.get('classes', [])))), format='html')
+            node.line = self.content_offset + 1
+            self.add_name(node)
+            return [node]
+
+        # Otherwise wrap it in a <div class="m-math">
         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)
index a1fc85fe21bcdd45b8c3a81ebd9dbfbfc1199bc1..42e3964940322c4ae594ce64ddacd0802c774139 100644 (file)
@@ -54,3 +54,12 @@ Structs:
     struct [label="{ a | b | { c | d | e }}" shape=record class="m-info"]
 
     another [label="a | { b | c } | d | e" shape=record]
+
+.. graph-figure:: This is a title.
+
+    .. digraph:: A to B
+        :class: m-info
+
+        a -> b
+
+    This is a description.
index 683e28dc4bbfbdf5f0e4f0b8111967c4b750fbc1..32203a2a7b18711bc646b2cc4c63f3fd791dbbfd 100644 (file)
@@ -39,6 +39,16 @@ the lines <code>W = \sum_{i=0}^{n} \frac{w_i}{h_i}</code> because
 \end{array}</pre>
 <p class="m-text m-big">Formulas <code>a^2</code> in big text are big.</p>
 <p class="m-text m-small">Formulas <code>a^2</code> in small text are small.</p>
+<figure class="m-code-figure">
+<pre>a^2 + b^2 = c^2</pre>
+<figcaption>This is a title.</figcaption>
+<p>This is a description.</p>
+</figure>
+<figure class="m-code-figure">
+<pre>a^2 + b^2 = c^2</pre>
+<p>The math below should not be styled as a part of the figure:</p>
+<pre>a^2 + b^2 = c^2</pre>
+</figure>
 <!-- /content -->
       </div>
     </div>
@@ -47,4 +57,3 @@ the lines <code>W = \sum_{i=0}^{n} \frac{w_i}{h_i}</code> because
 </main>
 </body>
 </html>
-
index 41f2b3c2e99d76a2e711006126f244dea1e6fd26..975af51fbe312442776b8c82b3358beed3b667ef 100644 (file)
@@ -289,6 +289,81 @@ a^2
 <use x='6.144944' xlink:href='#eq12-g1-50' y='-4.338437'/>
 </g>
 </svg> in small text are small.</p>
+<figure class="m-figure">
+<svg class="m-math m-info" style="width: 6.252em; height: 1.144em;" viewBox="164.01086 -10.98569 60.023139 10.98569">
+<title>
+a^2 + b^2 = c^2
+</title>
+<defs>
+<path d='M4.770112 -2.761644H8.069738C8.237111 -2.761644 8.452304 -2.761644 8.452304 -2.976837C8.452304 -3.203985 8.249066 -3.203985 8.069738 -3.203985H4.770112V-6.503611C4.770112 -6.670984 4.770112 -6.886177 4.554919 -6.886177C4.327771 -6.886177 4.327771 -6.682939 4.327771 -6.503611V-3.203985H1.028144C0.860772 -3.203985 0.645579 -3.203985 0.645579 -2.988792C0.645579 -2.761644 0.848817 -2.761644 1.028144 -2.761644H4.327771V0.537983C4.327771 0.705355 4.327771 0.920548 4.542964 0.920548C4.770112 0.920548 4.770112 0.71731 4.770112 0.537983V-2.761644Z' id='eq13-g2-43'/>
+<path d='M8.069738 -3.873474C8.237111 -3.873474 8.452304 -3.873474 8.452304 -4.088667C8.452304 -4.315816 8.249066 -4.315816 8.069738 -4.315816H1.028144C0.860772 -4.315816 0.645579 -4.315816 0.645579 -4.100623C0.645579 -3.873474 0.848817 -3.873474 1.028144 -3.873474H8.069738ZM8.069738 -1.649813C8.237111 -1.649813 8.452304 -1.649813 8.452304 -1.865006C8.452304 -2.092154 8.249066 -2.092154 8.069738 -2.092154H1.028144C0.860772 -2.092154 0.645579 -2.092154 0.645579 -1.876961C0.645579 -1.649813 0.848817 -1.649813 1.028144 -1.649813H8.069738Z' id='eq13-g2-61'/>
+<path d='M3.598506 -1.422665C3.53873 -1.219427 3.53873 -1.195517 3.371357 -0.968369C3.108344 -0.633624 2.582316 -0.119552 2.020423 -0.119552C1.530262 -0.119552 1.255293 -0.561893 1.255293 -1.267248C1.255293 -1.924782 1.625903 -3.263761 1.853051 -3.765878C2.259527 -4.60274 2.82142 -5.033126 3.287671 -5.033126C4.076712 -5.033126 4.23213 -4.052802 4.23213 -3.957161C4.23213 -3.945205 4.196264 -3.789788 4.184309 -3.765878L3.598506 -1.422665ZM4.363636 -4.483188C4.23213 -4.794022 3.90934 -5.272229 3.287671 -5.272229C1.936737 -5.272229 0.478207 -3.526775 0.478207 -1.75741C0.478207 -0.573848 1.171606 0.119552 1.984558 0.119552C2.642092 0.119552 3.203985 -0.394521 3.53873 -0.789041C3.658281 -0.083686 4.220174 0.119552 4.578829 0.119552S5.224408 -0.095641 5.439601 -0.526027C5.630884 -0.932503 5.798257 -1.661768 5.798257 -1.709589C5.798257 -1.769365 5.750436 -1.817186 5.678705 -1.817186C5.571108 -1.817186 5.559153 -1.75741 5.511333 -1.578082C5.332005 -0.872727 5.104857 -0.119552 4.614695 -0.119552C4.267995 -0.119552 4.244085 -0.430386 4.244085 -0.669489C4.244085 -0.944458 4.27995 -1.075965 4.387547 -1.542217C4.471233 -1.841096 4.531009 -2.10411 4.62665 -2.450809C5.068991 -4.244085 5.176588 -4.674471 5.176588 -4.746202C5.176588 -4.913574 5.045081 -5.045081 4.865753 -5.045081C4.483188 -5.045081 4.387547 -4.62665 4.363636 -4.483188Z' id='eq13-g0-97'/>
+<path d='M2.761644 -7.998007C2.773599 -8.045828 2.797509 -8.117559 2.797509 -8.177335C2.797509 -8.296887 2.677958 -8.296887 2.654047 -8.296887C2.642092 -8.296887 2.211706 -8.261021 1.996513 -8.237111C1.793275 -8.225156 1.613948 -8.201245 1.398755 -8.18929C1.111831 -8.16538 1.028144 -8.153425 1.028144 -7.938232C1.028144 -7.81868 1.147696 -7.81868 1.267248 -7.81868C1.876961 -7.81868 1.876961 -7.711083 1.876961 -7.591532C1.876961 -7.507846 1.78132 -7.161146 1.733499 -6.945953L1.446575 -5.798257C1.327024 -5.32005 0.645579 -2.606227 0.597758 -2.391034C0.537983 -2.092154 0.537983 -1.888917 0.537983 -1.733499C0.537983 -0.514072 1.219427 0.119552 1.996513 0.119552C3.383313 0.119552 4.817933 -1.661768 4.817933 -3.395268C4.817933 -4.495143 4.196264 -5.272229 3.299626 -5.272229C2.677958 -5.272229 2.116065 -4.758157 1.888917 -4.519054L2.761644 -7.998007ZM2.008468 -0.119552C1.625903 -0.119552 1.207472 -0.406476 1.207472 -1.338979C1.207472 -1.733499 1.243337 -1.960648 1.458531 -2.797509C1.494396 -2.952927 1.685679 -3.718057 1.733499 -3.873474C1.75741 -3.969116 2.462765 -5.033126 3.275716 -5.033126C3.801743 -5.033126 4.040847 -4.507098 4.040847 -3.88543C4.040847 -3.311582 3.706102 -1.960648 3.407223 -1.338979C3.108344 -0.6934 2.558406 -0.119552 2.008468 -0.119552Z' id='eq13-g0-98'/>
+<path d='M4.674471 -4.495143C4.447323 -4.495143 4.339726 -4.495143 4.172354 -4.351681C4.100623 -4.291905 3.969116 -4.112578 3.969116 -3.921295C3.969116 -3.682192 4.148443 -3.53873 4.375592 -3.53873C4.662516 -3.53873 4.985305 -3.777833 4.985305 -4.25604C4.985305 -4.829888 4.435367 -5.272229 3.610461 -5.272229C2.044334 -5.272229 0.478207 -3.56264 0.478207 -1.865006C0.478207 -0.824907 1.123786 0.119552 2.343213 0.119552C3.969116 0.119552 4.99726 -1.147696 4.99726 -1.303113C4.99726 -1.374844 4.925529 -1.43462 4.877709 -1.43462C4.841843 -1.43462 4.829888 -1.422665 4.722291 -1.315068C3.957161 -0.298879 2.82142 -0.119552 2.367123 -0.119552C1.542217 -0.119552 1.279203 -0.836862 1.279203 -1.43462C1.279203 -1.853051 1.482441 -3.012702 1.912827 -3.825654C2.223661 -4.387547 2.86924 -5.033126 3.622416 -5.033126C3.777833 -5.033126 4.435367 -5.009215 4.674471 -4.495143Z' id='eq13-g0-99'/>
+<path d='M2.247572 -1.625903C2.375093 -1.745455 2.709838 -2.008468 2.83736 -2.12005C3.331507 -2.574346 3.801743 -3.012702 3.801743 -3.737983C3.801743 -4.686426 3.004732 -5.300125 2.008468 -5.300125C1.052055 -5.300125 0.422416 -4.574844 0.422416 -3.865504C0.422416 -3.474969 0.73325 -3.419178 0.844832 -3.419178C1.012204 -3.419178 1.259278 -3.53873 1.259278 -3.841594C1.259278 -4.25604 0.860772 -4.25604 0.765131 -4.25604C0.996264 -4.837858 1.530262 -5.037111 1.920797 -5.037111C2.662017 -5.037111 3.044583 -4.407472 3.044583 -3.737983C3.044583 -2.909091 2.462765 -2.303362 1.522291 -1.338979L0.518057 -0.302864C0.422416 -0.215193 0.422416 -0.199253 0.422416 0H3.57061L3.801743 -1.42665H3.55467C3.53076 -1.267248 3.466999 -0.868742 3.371357 -0.71731C3.323537 -0.653549 2.717808 -0.653549 2.590286 -0.653549H1.171606L2.247572 -1.625903Z' id='eq13-g1-50'/>
+</defs>
+<g id='eq13-page1'>
+<use x='164.01086' xlink:href='#eq13-g0-97' y='-0.913201'/>
+<use x='170.155804' xlink:href='#eq13-g1-50' y='-5.849387'/>
+<use x='177.544782' xlink:href='#eq13-g2-43' y='-0.913201'/>
+<use x='189.306097' xlink:href='#eq13-g0-98' y='-0.913201'/>
+<use x='194.283203' xlink:href='#eq13-g1-50' y='-5.849387'/>
+<use x='202.336347' xlink:href='#eq13-g2-61' y='-0.913201'/>
+<use x='214.761828' xlink:href='#eq13-g0-99' y='-0.913201'/>
+<use x='219.799816' xlink:href='#eq13-g1-50' y='-5.849387'/>
+</g>
+</svg><figcaption>This is a title.</figcaption>
+<p>This is a description.</p>
+</figure>
+<figure class="m-figure">
+<svg class="m-math" style="width: 6.252em; height: 1.144em;" viewBox="164.01086 -10.98569 60.023139 10.98569">
+<title>
+a^2 + b^2 = c^2
+</title>
+<defs>
+<path d='M4.770112 -2.761644H8.069738C8.237111 -2.761644 8.452304 -2.761644 8.452304 -2.976837C8.452304 -3.203985 8.249066 -3.203985 8.069738 -3.203985H4.770112V-6.503611C4.770112 -6.670984 4.770112 -6.886177 4.554919 -6.886177C4.327771 -6.886177 4.327771 -6.682939 4.327771 -6.503611V-3.203985H1.028144C0.860772 -3.203985 0.645579 -3.203985 0.645579 -2.988792C0.645579 -2.761644 0.848817 -2.761644 1.028144 -2.761644H4.327771V0.537983C4.327771 0.705355 4.327771 0.920548 4.542964 0.920548C4.770112 0.920548 4.770112 0.71731 4.770112 0.537983V-2.761644Z' id='eq14-g2-43'/>
+<path d='M8.069738 -3.873474C8.237111 -3.873474 8.452304 -3.873474 8.452304 -4.088667C8.452304 -4.315816 8.249066 -4.315816 8.069738 -4.315816H1.028144C0.860772 -4.315816 0.645579 -4.315816 0.645579 -4.100623C0.645579 -3.873474 0.848817 -3.873474 1.028144 -3.873474H8.069738ZM8.069738 -1.649813C8.237111 -1.649813 8.452304 -1.649813 8.452304 -1.865006C8.452304 -2.092154 8.249066 -2.092154 8.069738 -2.092154H1.028144C0.860772 -2.092154 0.645579 -2.092154 0.645579 -1.876961C0.645579 -1.649813 0.848817 -1.649813 1.028144 -1.649813H8.069738Z' id='eq14-g2-61'/>
+<path d='M3.598506 -1.422665C3.53873 -1.219427 3.53873 -1.195517 3.371357 -0.968369C3.108344 -0.633624 2.582316 -0.119552 2.020423 -0.119552C1.530262 -0.119552 1.255293 -0.561893 1.255293 -1.267248C1.255293 -1.924782 1.625903 -3.263761 1.853051 -3.765878C2.259527 -4.60274 2.82142 -5.033126 3.287671 -5.033126C4.076712 -5.033126 4.23213 -4.052802 4.23213 -3.957161C4.23213 -3.945205 4.196264 -3.789788 4.184309 -3.765878L3.598506 -1.422665ZM4.363636 -4.483188C4.23213 -4.794022 3.90934 -5.272229 3.287671 -5.272229C1.936737 -5.272229 0.478207 -3.526775 0.478207 -1.75741C0.478207 -0.573848 1.171606 0.119552 1.984558 0.119552C2.642092 0.119552 3.203985 -0.394521 3.53873 -0.789041C3.658281 -0.083686 4.220174 0.119552 4.578829 0.119552S5.224408 -0.095641 5.439601 -0.526027C5.630884 -0.932503 5.798257 -1.661768 5.798257 -1.709589C5.798257 -1.769365 5.750436 -1.817186 5.678705 -1.817186C5.571108 -1.817186 5.559153 -1.75741 5.511333 -1.578082C5.332005 -0.872727 5.104857 -0.119552 4.614695 -0.119552C4.267995 -0.119552 4.244085 -0.430386 4.244085 -0.669489C4.244085 -0.944458 4.27995 -1.075965 4.387547 -1.542217C4.471233 -1.841096 4.531009 -2.10411 4.62665 -2.450809C5.068991 -4.244085 5.176588 -4.674471 5.176588 -4.746202C5.176588 -4.913574 5.045081 -5.045081 4.865753 -5.045081C4.483188 -5.045081 4.387547 -4.62665 4.363636 -4.483188Z' id='eq14-g0-97'/>
+<path d='M2.761644 -7.998007C2.773599 -8.045828 2.797509 -8.117559 2.797509 -8.177335C2.797509 -8.296887 2.677958 -8.296887 2.654047 -8.296887C2.642092 -8.296887 2.211706 -8.261021 1.996513 -8.237111C1.793275 -8.225156 1.613948 -8.201245 1.398755 -8.18929C1.111831 -8.16538 1.028144 -8.153425 1.028144 -7.938232C1.028144 -7.81868 1.147696 -7.81868 1.267248 -7.81868C1.876961 -7.81868 1.876961 -7.711083 1.876961 -7.591532C1.876961 -7.507846 1.78132 -7.161146 1.733499 -6.945953L1.446575 -5.798257C1.327024 -5.32005 0.645579 -2.606227 0.597758 -2.391034C0.537983 -2.092154 0.537983 -1.888917 0.537983 -1.733499C0.537983 -0.514072 1.219427 0.119552 1.996513 0.119552C3.383313 0.119552 4.817933 -1.661768 4.817933 -3.395268C4.817933 -4.495143 4.196264 -5.272229 3.299626 -5.272229C2.677958 -5.272229 2.116065 -4.758157 1.888917 -4.519054L2.761644 -7.998007ZM2.008468 -0.119552C1.625903 -0.119552 1.207472 -0.406476 1.207472 -1.338979C1.207472 -1.733499 1.243337 -1.960648 1.458531 -2.797509C1.494396 -2.952927 1.685679 -3.718057 1.733499 -3.873474C1.75741 -3.969116 2.462765 -5.033126 3.275716 -5.033126C3.801743 -5.033126 4.040847 -4.507098 4.040847 -3.88543C4.040847 -3.311582 3.706102 -1.960648 3.407223 -1.338979C3.108344 -0.6934 2.558406 -0.119552 2.008468 -0.119552Z' id='eq14-g0-98'/>
+<path d='M4.674471 -4.495143C4.447323 -4.495143 4.339726 -4.495143 4.172354 -4.351681C4.100623 -4.291905 3.969116 -4.112578 3.969116 -3.921295C3.969116 -3.682192 4.148443 -3.53873 4.375592 -3.53873C4.662516 -3.53873 4.985305 -3.777833 4.985305 -4.25604C4.985305 -4.829888 4.435367 -5.272229 3.610461 -5.272229C2.044334 -5.272229 0.478207 -3.56264 0.478207 -1.865006C0.478207 -0.824907 1.123786 0.119552 2.343213 0.119552C3.969116 0.119552 4.99726 -1.147696 4.99726 -1.303113C4.99726 -1.374844 4.925529 -1.43462 4.877709 -1.43462C4.841843 -1.43462 4.829888 -1.422665 4.722291 -1.315068C3.957161 -0.298879 2.82142 -0.119552 2.367123 -0.119552C1.542217 -0.119552 1.279203 -0.836862 1.279203 -1.43462C1.279203 -1.853051 1.482441 -3.012702 1.912827 -3.825654C2.223661 -4.387547 2.86924 -5.033126 3.622416 -5.033126C3.777833 -5.033126 4.435367 -5.009215 4.674471 -4.495143Z' id='eq14-g0-99'/>
+<path d='M2.247572 -1.625903C2.375093 -1.745455 2.709838 -2.008468 2.83736 -2.12005C3.331507 -2.574346 3.801743 -3.012702 3.801743 -3.737983C3.801743 -4.686426 3.004732 -5.300125 2.008468 -5.300125C1.052055 -5.300125 0.422416 -4.574844 0.422416 -3.865504C0.422416 -3.474969 0.73325 -3.419178 0.844832 -3.419178C1.012204 -3.419178 1.259278 -3.53873 1.259278 -3.841594C1.259278 -4.25604 0.860772 -4.25604 0.765131 -4.25604C0.996264 -4.837858 1.530262 -5.037111 1.920797 -5.037111C2.662017 -5.037111 3.044583 -4.407472 3.044583 -3.737983C3.044583 -2.909091 2.462765 -2.303362 1.522291 -1.338979L0.518057 -0.302864C0.422416 -0.215193 0.422416 -0.199253 0.422416 0H3.57061L3.801743 -1.42665H3.55467C3.53076 -1.267248 3.466999 -0.868742 3.371357 -0.71731C3.323537 -0.653549 2.717808 -0.653549 2.590286 -0.653549H1.171606L2.247572 -1.625903Z' id='eq14-g1-50'/>
+</defs>
+<g id='eq14-page1'>
+<use x='164.01086' xlink:href='#eq14-g0-97' y='-0.913201'/>
+<use x='170.155804' xlink:href='#eq14-g1-50' y='-5.849387'/>
+<use x='177.544782' xlink:href='#eq14-g2-43' y='-0.913201'/>
+<use x='189.306097' xlink:href='#eq14-g0-98' y='-0.913201'/>
+<use x='194.283203' xlink:href='#eq14-g1-50' y='-5.849387'/>
+<use x='202.336347' xlink:href='#eq14-g2-61' y='-0.913201'/>
+<use x='214.761828' xlink:href='#eq14-g0-99' y='-0.913201'/>
+<use x='219.799816' xlink:href='#eq14-g1-50' y='-5.849387'/>
+</g>
+</svg><p>The math below should not be styled as a part of the figure:</p>
+<div class="m-danger m-math">
+<svg style="width: 6.252em; height: 1.144em;" viewBox="164.01086 -10.98569 60.023139 10.98569">
+<title>
+a^2 + b^2 = c^2
+</title>
+<defs>
+<path d='M4.770112 -2.761644H8.069738C8.237111 -2.761644 8.452304 -2.761644 8.452304 -2.976837C8.452304 -3.203985 8.249066 -3.203985 8.069738 -3.203985H4.770112V-6.503611C4.770112 -6.670984 4.770112 -6.886177 4.554919 -6.886177C4.327771 -6.886177 4.327771 -6.682939 4.327771 -6.503611V-3.203985H1.028144C0.860772 -3.203985 0.645579 -3.203985 0.645579 -2.988792C0.645579 -2.761644 0.848817 -2.761644 1.028144 -2.761644H4.327771V0.537983C4.327771 0.705355 4.327771 0.920548 4.542964 0.920548C4.770112 0.920548 4.770112 0.71731 4.770112 0.537983V-2.761644Z' id='eq15-g2-43'/>
+<path d='M8.069738 -3.873474C8.237111 -3.873474 8.452304 -3.873474 8.452304 -4.088667C8.452304 -4.315816 8.249066 -4.315816 8.069738 -4.315816H1.028144C0.860772 -4.315816 0.645579 -4.315816 0.645579 -4.100623C0.645579 -3.873474 0.848817 -3.873474 1.028144 -3.873474H8.069738ZM8.069738 -1.649813C8.237111 -1.649813 8.452304 -1.649813 8.452304 -1.865006C8.452304 -2.092154 8.249066 -2.092154 8.069738 -2.092154H1.028144C0.860772 -2.092154 0.645579 -2.092154 0.645579 -1.876961C0.645579 -1.649813 0.848817 -1.649813 1.028144 -1.649813H8.069738Z' id='eq15-g2-61'/>
+<path d='M3.598506 -1.422665C3.53873 -1.219427 3.53873 -1.195517 3.371357 -0.968369C3.108344 -0.633624 2.582316 -0.119552 2.020423 -0.119552C1.530262 -0.119552 1.255293 -0.561893 1.255293 -1.267248C1.255293 -1.924782 1.625903 -3.263761 1.853051 -3.765878C2.259527 -4.60274 2.82142 -5.033126 3.287671 -5.033126C4.076712 -5.033126 4.23213 -4.052802 4.23213 -3.957161C4.23213 -3.945205 4.196264 -3.789788 4.184309 -3.765878L3.598506 -1.422665ZM4.363636 -4.483188C4.23213 -4.794022 3.90934 -5.272229 3.287671 -5.272229C1.936737 -5.272229 0.478207 -3.526775 0.478207 -1.75741C0.478207 -0.573848 1.171606 0.119552 1.984558 0.119552C2.642092 0.119552 3.203985 -0.394521 3.53873 -0.789041C3.658281 -0.083686 4.220174 0.119552 4.578829 0.119552S5.224408 -0.095641 5.439601 -0.526027C5.630884 -0.932503 5.798257 -1.661768 5.798257 -1.709589C5.798257 -1.769365 5.750436 -1.817186 5.678705 -1.817186C5.571108 -1.817186 5.559153 -1.75741 5.511333 -1.578082C5.332005 -0.872727 5.104857 -0.119552 4.614695 -0.119552C4.267995 -0.119552 4.244085 -0.430386 4.244085 -0.669489C4.244085 -0.944458 4.27995 -1.075965 4.387547 -1.542217C4.471233 -1.841096 4.531009 -2.10411 4.62665 -2.450809C5.068991 -4.244085 5.176588 -4.674471 5.176588 -4.746202C5.176588 -4.913574 5.045081 -5.045081 4.865753 -5.045081C4.483188 -5.045081 4.387547 -4.62665 4.363636 -4.483188Z' id='eq15-g0-97'/>
+<path d='M2.761644 -7.998007C2.773599 -8.045828 2.797509 -8.117559 2.797509 -8.177335C2.797509 -8.296887 2.677958 -8.296887 2.654047 -8.296887C2.642092 -8.296887 2.211706 -8.261021 1.996513 -8.237111C1.793275 -8.225156 1.613948 -8.201245 1.398755 -8.18929C1.111831 -8.16538 1.028144 -8.153425 1.028144 -7.938232C1.028144 -7.81868 1.147696 -7.81868 1.267248 -7.81868C1.876961 -7.81868 1.876961 -7.711083 1.876961 -7.591532C1.876961 -7.507846 1.78132 -7.161146 1.733499 -6.945953L1.446575 -5.798257C1.327024 -5.32005 0.645579 -2.606227 0.597758 -2.391034C0.537983 -2.092154 0.537983 -1.888917 0.537983 -1.733499C0.537983 -0.514072 1.219427 0.119552 1.996513 0.119552C3.383313 0.119552 4.817933 -1.661768 4.817933 -3.395268C4.817933 -4.495143 4.196264 -5.272229 3.299626 -5.272229C2.677958 -5.272229 2.116065 -4.758157 1.888917 -4.519054L2.761644 -7.998007ZM2.008468 -0.119552C1.625903 -0.119552 1.207472 -0.406476 1.207472 -1.338979C1.207472 -1.733499 1.243337 -1.960648 1.458531 -2.797509C1.494396 -2.952927 1.685679 -3.718057 1.733499 -3.873474C1.75741 -3.969116 2.462765 -5.033126 3.275716 -5.033126C3.801743 -5.033126 4.040847 -4.507098 4.040847 -3.88543C4.040847 -3.311582 3.706102 -1.960648 3.407223 -1.338979C3.108344 -0.6934 2.558406 -0.119552 2.008468 -0.119552Z' id='eq15-g0-98'/>
+<path d='M4.674471 -4.495143C4.447323 -4.495143 4.339726 -4.495143 4.172354 -4.351681C4.100623 -4.291905 3.969116 -4.112578 3.969116 -3.921295C3.969116 -3.682192 4.148443 -3.53873 4.375592 -3.53873C4.662516 -3.53873 4.985305 -3.777833 4.985305 -4.25604C4.985305 -4.829888 4.435367 -5.272229 3.610461 -5.272229C2.044334 -5.272229 0.478207 -3.56264 0.478207 -1.865006C0.478207 -0.824907 1.123786 0.119552 2.343213 0.119552C3.969116 0.119552 4.99726 -1.147696 4.99726 -1.303113C4.99726 -1.374844 4.925529 -1.43462 4.877709 -1.43462C4.841843 -1.43462 4.829888 -1.422665 4.722291 -1.315068C3.957161 -0.298879 2.82142 -0.119552 2.367123 -0.119552C1.542217 -0.119552 1.279203 -0.836862 1.279203 -1.43462C1.279203 -1.853051 1.482441 -3.012702 1.912827 -3.825654C2.223661 -4.387547 2.86924 -5.033126 3.622416 -5.033126C3.777833 -5.033126 4.435367 -5.009215 4.674471 -4.495143Z' id='eq15-g0-99'/>
+<path d='M2.247572 -1.625903C2.375093 -1.745455 2.709838 -2.008468 2.83736 -2.12005C3.331507 -2.574346 3.801743 -3.012702 3.801743 -3.737983C3.801743 -4.686426 3.004732 -5.300125 2.008468 -5.300125C1.052055 -5.300125 0.422416 -4.574844 0.422416 -3.865504C0.422416 -3.474969 0.73325 -3.419178 0.844832 -3.419178C1.012204 -3.419178 1.259278 -3.53873 1.259278 -3.841594C1.259278 -4.25604 0.860772 -4.25604 0.765131 -4.25604C0.996264 -4.837858 1.530262 -5.037111 1.920797 -5.037111C2.662017 -5.037111 3.044583 -4.407472 3.044583 -3.737983C3.044583 -2.909091 2.462765 -2.303362 1.522291 -1.338979L0.518057 -0.302864C0.422416 -0.215193 0.422416 -0.199253 0.422416 0H3.57061L3.801743 -1.42665H3.55467C3.53076 -1.267248 3.466999 -0.868742 3.371357 -0.71731C3.323537 -0.653549 2.717808 -0.653549 2.590286 -0.653549H1.171606L2.247572 -1.625903Z' id='eq15-g1-50'/>
+</defs>
+<g id='eq15-page1'>
+<use x='164.01086' xlink:href='#eq15-g0-97' y='-0.913201'/>
+<use x='170.155804' xlink:href='#eq15-g1-50' y='-5.849387'/>
+<use x='177.544782' xlink:href='#eq15-g2-43' y='-0.913201'/>
+<use x='189.306097' xlink:href='#eq15-g0-98' y='-0.913201'/>
+<use x='194.283203' xlink:href='#eq15-g1-50' y='-5.849387'/>
+<use x='202.336347' xlink:href='#eq15-g2-61' y='-0.913201'/>
+<use x='214.761828' xlink:href='#eq15-g0-99' y='-0.913201'/>
+<use x='219.799816' xlink:href='#eq15-g1-50' y='-5.849387'/>
+</g>
+</svg></div>
+</figure>
 <!-- /content -->
       </div>
     </div>
index 3f58c9a7cfad128ff1ab5ba8cdd0d6fa97852365..465cb246e215c802989a6bef0e7691baf9281426 100644 (file)
@@ -42,3 +42,25 @@ Formulas :math:`a^2` in big text are big.
 .. class:: m-text m-small
 
 Formulas :math:`a^2` in small text are small.
+
+.. math-figure:: This is a title.
+
+    .. math::
+        :class: m-info
+
+        a^2 + b^2 = c^2
+
+    This is a description.
+
+.. math-figure::
+
+    .. math::
+
+        a^2 + b^2 = c^2
+
+    The math below should not be styled as a part of the figure:
+
+    .. math::
+        :class: m-danger
+
+        a^2 + b^2 = c^2
index 272d35af4e342afc42fad658018651b7c1c77497..68659e6af85b7cc9ff61c5d06ddd44df4747fb3b 100644 (file)
@@ -42,7 +42,7 @@ class Math(PluginTestCase):
                          "The math plugin requires at least Python 3.5 and LaTeX installed")
     def test(self):
         self.run_pelican({
-            'PLUGINS': ['m.htmlsanity', 'm.math'],
+            'PLUGINS': ['m.htmlsanity', 'm.components', 'm.math'],
             'M_MATH_CACHE_FILE': None
         })