2018-03-02 07:52:39 -06:00
|
|
|
from docutils.parsers.rst import Directive
|
|
|
|
|
|
|
|
from sphinx.ext.mathbase import math, displaymath
|
2018-05-14 20:57:07 -05:00
|
|
|
|
|
|
|
extensions = ['sphinx.ext.mathjax']
|
|
|
|
|
|
|
|
|
|
|
|
def my_math_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
|
|
return [math(latex='E = mc^2')], []
|
|
|
|
|
|
|
|
|
2018-03-02 07:52:39 -06:00
|
|
|
class MyMathDirective(Directive):
|
|
|
|
def run(self):
|
|
|
|
return [displaymath(latex='E = mc^2')]
|
|
|
|
|
|
|
|
|
2018-05-14 20:57:07 -05:00
|
|
|
def setup(app):
|
|
|
|
app.add_role('my_math', my_math_role)
|
2018-03-02 07:52:39 -06:00
|
|
|
app.add_directive('my-math', MyMathDirective)
|