How to use cmarkgfm - 10 common examples

To help you get started, we’ve selected a few cmarkgfm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_find_syntax_extension():
    extension = cmark.find_syntax_extension('table')
    assert extension is not None
github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_find_syntax_extension_doesnt_exist():
    extension = cmark.find_syntax_extension('notarealext')
    assert extension is None
github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_github_flavored_markdown_to_html():
    text = u"Hello, https://pypa.io!"
    result = cmark.github_flavored_markdown_to_html(text)
    assert result == textwrap.dedent("""\
        <p>Hello, <a href="https://pypa.io">https://pypa.io</a>!</p>\n""")
github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_github_flavored_markdown_to_html_pre_tag():
    text = u"```python\nprint('hello')\n```"
    result = cmark.github_flavored_markdown_to_html(text)
    assert result == textwrap.dedent("""\
        <pre><code class="language-python">print('hello')</code></pre>
github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_render_html():
    text = u"Hello, **world**!"
    root = cmark.parse_document(text)
    result = cmark.render_html(root)
    assert result == '<p>Hello, <strong>world</strong>!</p>\n'
github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_parse_document():
    text = u"Hello, **world**!"
    result = cmark.parse_document(text)
    assert result is not None
github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_render_html():
    text = u"Hello, **world**!"
    root = cmark.parse_document(text)
    result = cmark.render_html(root)
    assert result == '<p>Hello, <strong>world</strong>!</p>\n'
github theacodes / cmarkgfm / tests / test_cmark.py View on Github external
def test_parser_interface():
    text = u"Hello, **world**!"
    parser = cmark.parser_new()
    cmark.parser_feed(parser, text)
    root = cmark.parser_finish(parser)
    result = cmark.render_html(root)
    cmark.parser_free(parser)
    assert result == '<p>Hello, <strong>world</strong>!</p>\n'
github theacodes / cmarkgfm / src / cmarkgfm / cmark.py View on Github external
"""Python bindings to GitHub's cmark Markdown library."""

from __future__ import unicode_literals

from cmarkgfm import _cmark


class Options(object):
    CMARK_OPT_DEFAULT = _cmark.lib.CMARK_OPT_DEFAULT
    CMARK_OPT_SOURCEPOS = _cmark.lib.CMARK_OPT_SOURCEPOS
    CMARK_OPT_HARDBREAKS = _cmark.lib.CMARK_OPT_HARDBREAKS
    CMARK_OPT_UNSAFE = _cmark.lib.CMARK_OPT_UNSAFE
    CMARK_OPT_NOBREAKS = _cmark.lib.CMARK_OPT_NOBREAKS
    CMARK_OPT_NORMALIZE = _cmark.lib.CMARK_OPT_NORMALIZE
    CMARK_OPT_VALIDATE_UTF8 = _cmark.lib.CMARK_OPT_VALIDATE_UTF8
    CMARK_OPT_SMART = _cmark.lib.CMARK_OPT_SMART
    CMARK_OPT_GITHUB_PRE_LANG = _cmark.lib.CMARK_OPT_GITHUB_PRE_LANG
    CMARK_OPT_LIBERAL_HTML_TAG = _cmark.lib.CMARK_OPT_LIBERAL_HTML_TAG
    CMARK_OPT_FOOTNOTES = _cmark.lib.CMARK_OPT_FOOTNOTES
    CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE = (
        _cmark.lib.CMARK_OPT_STRIKETHROUGH_DOUBLE_TILDE)
    CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES = (
        _cmark.lib.CMARK_OPT_TABLE_PREFER_STYLE_ATTRIBUTES)
github theacodes / cmarkgfm / src / cmarkgfm / cmark.py View on Github external
def parser_feed(parser, text):
    """Direct wrapper over cmark_parser_feed."""
    encoded_text = text.encode('utf-8')
    return _cmark.lib.cmark_parser_feed(
        parser, encoded_text, len(encoded_text))