示例#1
0
def test_escape_in_code_remains_unchanged():
    text, should = __wrap(
        r'abc `\\( some _not_ latex text \)` abc',
        r'<p>abc <code>\\( some _not_ latex text \)</code> abc</p>'
    )
    output = render(text)
    assert output == should
示例#2
0
def test_latex_with_ampersand():
    text, should = __wrap(
        r'$$ a & b & c \\ $$',
        r'$$ a & b & c \\ $$' + '\n'
    )
    output = render(text)
    assert output == should
示例#3
0
def test_escape_latex_markers():
    text, should = __wrap(
        r'abc \\( some _not_ latex text \) abc',
        r'<p>abc \( some <em>not</em> latex text ) abc</p>'
    )
    output = render(text)
    assert output == should
示例#4
0
def test_latex_inline_with_underline():
    text, should = __wrap(
        r'abc \( \mathop{P}_{2}=x_{4} \) abc',
        r'<p>abc \( \mathop{P}_{2}=x_{4} \) abc</p>'
    )
    output = render(text)
    assert output == should
示例#5
0
def test_code():
    text, should = __wrap(
        '```\nimport pandas\n```',
        '<pre><code>import pandas\n</code></pre>\n'
    )
    output = render(text)
    assert output == should
示例#6
0
文件: pages.py 项目: Wolfenberg/notes
def page(page_id):
    page = storage_service().get_page(page_id)
    files = uploads_service().list_attachments(page_id)
    content = markdown.render(page.body)
    return flask.render_template('pages/page.html',
                                 content=content,
                                 page=page,
                                 files=files)
示例#7
0
def test_no_latex_in_code():
    text, should = __wrap(
        '\n'.join([
            r'```',
            r' $$ sh test.sh',
            r' $$ ls',
            r'```']),
        '\n'.join([
            r'<pre><code> $$ sh test.sh',
            r' $$ ls',
            r'</code></pre>',
            r''])
    )
    output = render(text)
    assert output == should
示例#8
0
def test_no_latex_in_offset_formatted_code():
    text = '\n'.join([
        r'text',
        r'',
        r'    \(code\) 1',
        r'    code2',
        r'',
        r'text'
    ])
    expect = '\n'.join([
        r'<p>text</p>',
        r'<pre><code>\(code\) 1',
        r'code2',
        r'</code></pre>',
        r'<p>text</p>'
    ])
    assert render(text) == expect
示例#9
0
def test_headers():
    text = '# header'
    output = render(text)
    assert output == '<h1>header</h1>'
示例#10
0
def test_emphasis():
    text, should = __wrap('text _with_ emphasis',
                          '<p>text <em>with</em> emphasis</p>')
    output = render(text)
    assert output == should