-
-
Save navanchauhan/041c91d0181be95add33c26d61f6433f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from markdown2 import Markdown | |
md = Markdown(extras=["fenced-code-blocks", "latex"]) | |
test_string = r"""## Simple Test | |
Inline Equations can be written as $y=mx+b$. | |
Block equations are wrapped using | |
$$ | |
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} | |
$$ | |
This extra does not run inside fenced-blocks, so | |
``` | |
some random code, describing $a and $b won't accidentally render $y=mx$ | |
``` | |
""" | |
print(md.convert(test_string)) | |
""" Output: | |
<h2>Simple Test</h2> | |
<p>Inline Equations can be written as <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>y</mi><mo>=</mo><mi>m</mi><mi>x</mi><mo>+</mo><mi>b</mi></mrow></math>.</p> | |
<p>Block equations are wrapped using</p> | |
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow><mi>x</mi><mo>=</mo><mfrac><mrow><mo>−</mo><mi>b</mi><mi>±</mi><msqrt><mrow><msup><mi>b</mi><mn>2</mn></msup><mo>−</mo><mn>4</mn><mi>a</mi><mi>c</mi></mrow></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac></mrow></math> | |
<p>This extra does not run inside fenced-blocks, so </p> | |
<pre><code>some random code, describing $a and $b won't accidentally render $y=mx$ | |
</code></pre> | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment