# Path: mistletoe/block_token.py
# class Document(BlockToken):
#     """
#     Document token.
#     """
#     def __init__(self, lines):
#         if isinstance(lines, str):
#             lines = lines.splitlines(keepends=True)
#         lines = [line if line.endswith('\n') else '{}\n'.format(line) for line in lines]
#         self.footnotes = {}
#         global _root_node
#         _root_node = self
#         span_token._root_node = self
#         self.children = tokenize(lines)
#         span_token._root_node = None
#         _root_node = None
# 
# Path: contrib/mathjax.py
# class MathJaxRenderer(HTMLRenderer, LaTeXRenderer):
#     """
#     MRO will first look for render functions under HTMLRenderer,
#     then LaTeXRenderer.
#     """
#     mathjax_src = '<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>\n'
# 
#     def render_math(self, token):
#         """
#         Ensure Math tokens are all enclosed in two dollar signs.
#         """
#         if token.content.startswith('$$'):
#             return self.render_raw_text(token)
#         return '${}$'.format(self.render_raw_text(token))
# 
#     def render_document(self, token):
#         """
#         Append CDN link for MathJax to the end of <body>.
#         """
#         return super().render_document(token) + self.mathjax_src


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:

# Path: mistletoe/block_token.py
# class Document(BlockToken):
#     """
#     Document token.
#     """
#     def __init__(self, lines):
#         if isinstance(lines, str):
#             lines = lines.splitlines(keepends=True)
#         lines = [line if line.endswith('\n') else '{}\n'.format(line) for line in lines]
#         self.footnotes = {}
#         global _root_node
#         _root_node = self
#         span_token._root_node = self
#         self.children = tokenize(lines)
#         span_token._root_node = None
#         _root_node = None
# 
# Path: contrib/mathjax.py
# class MathJaxRenderer(HTMLRenderer, LaTeXRenderer):
#     """
#     MRO will first look for render functions under HTMLRenderer,
#     then LaTeXRenderer.
#     """
#     mathjax_src = '<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML"></script>\n'
# 
#     def render_math(self, token):
#         """
#         Ensure Math tokens are all enclosed in two dollar signs.
#         """
#         if token.content.startswith('$$'):
#             return self.render_raw_text(token)
#         return '${}$'.format(self.render_raw_text(token))
# 
#     def render_document(self, token):
#         """
#         Append CDN link for MathJax to the end of <body>.
#         """
#         return super().render_document(token) + self.mathjax_src


# Path: test/test_contrib/test_mathjax.py
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'])