Files
sphinx/tests/roots/test-ext-math-compat/conf.py
2025-01-03 01:33:14 +00:00

21 lines
502 B
Python

from docutils import nodes
from docutils.parsers.rst import Directive
extensions = ['sphinx.ext.mathjax']
def my_math_role(role, rawtext, text, lineno, inliner, options={}, content=[]): # NoQA: B006
text = 'E = mc^2'
return [nodes.math(text, text)], []
class MyMathDirective(Directive):
def run(self):
text = 'E = mc^2'
return [nodes.math_block(text, text)]
def setup(app):
app.add_role('my_math', my_math_role)
app.add_directive('my-math', MyMathDirective)