Пример #1
0
def test_custom_renderer():
    class MyRenderer(CodeRenderer):
        def block_code(self, *args):
            return 'nope'
    ret = highlight(
        'hello\n'
        '```\n'
        'world\n'
        '```\n',
        Renderer=MyRenderer,
    )
    assert ret == '<p>hello</p>\nnope'
Пример #2
0
def test_highlight_plain_text():
    ret = highlight(
        '```\n'
        'this is plain text, such class.\n'
        '```\n'
    )
    assert ret == (
        '<div class="highlight"><pre>'
        '<span></span>'
        'this is plain text, such class.\n'
        '</pre></div>\n'
    )
Пример #3
0
def test_invalid_lang():
    ret = highlight(
        '```wombats\n'
        'wombats is not a language, but it should be\n'
        '```\n'
    )
    assert ret == (
        '<div class="highlight"><pre>'
        '<span></span>'
        'wombats is not a language, but it should be\n'
        '</pre></div>\n'
    )
Пример #4
0
def test_highlight_python():
    ret = highlight(
        '```python\n'
        'print("hello world")\n'
        '```\n'
    )
    assert ret == (
        '<div class="highlight python"><pre>'
        '<span></span>'
        '<span class="k">print</span>'
        '<span class="p">(</span>'
        '<span class="s2">&quot;hello world&quot;</span>'
        '<span class="p">)</span>\n'
        '</pre></div>\n'
    )
Пример #5
0
def test_simple_markdown():
    ret = highlight('## ohai\n')
    assert ret == '<h2>ohai</h2>\n'