File: test_mathjax.py

package info (click to toggle)
python-mistletoe 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 632 kB
  • sloc: python: 3,442; sh: 71; makefile: 45
file content (23 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import unittest
from mistletoe import Document
from contrib.mathjax import MathJaxRenderer

class TestMathJaxRenderer(unittest.TestCase):
    mathjax_src = '<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>\n'

    def test_render_html(self):
        with MathJaxRenderer() as renderer:
            token = Document(['# heading 1\n', 'paragraph\n'])
            output = renderer.render(token)
            target = '<h1>heading 1</h1>\n<p>paragraph</p>\n'
            target += self.mathjax_src
            self.assertEqual(output, target)

    def test_render_math(self):
        with MathJaxRenderer() as renderer:
            raw = ['# heading 1\n', '$$paragraph$$\n', 'with $ math $\n']
            token = Document(raw)
            output = renderer.render(token)
            target = '<h1>heading 1</h1>\n<p>$$paragraph$$\nwith $$ math $$</p>\n'
            target += self.mathjax_src
            self.assertEqual(output, target)