mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
20 lines
465 B
Python
20 lines
465 B
Python
from docutils.parsers.rst import Directive
|
|
|
|
from sphinx.ext.mathbase import math, displaymath
|
|
|
|
extensions = ['sphinx.ext.mathjax']
|
|
|
|
|
|
def my_math_role(role, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
return [math(latex='E = mc^2')], []
|
|
|
|
|
|
class MyMathDirective(Directive):
|
|
def run(self):
|
|
return [displaymath(latex='E = mc^2')]
|
|
|
|
|
|
def setup(app):
|
|
app.add_role('my_math', my_math_role)
|
|
app.add_directive('my-math', MyMathDirective)
|