mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
21 lines
502 B
Python
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)
|