Very lightweight CFFI-based Python bindings to cmark library (CommonMark implementation in C).
Project description
paka.cmark is a Python library that wraps subset of cmark C library (that is one of reference implementations of CommonMark).
Features
Python 2.7 and 3.5 are supported
PyPy (Python 2.7) is supported, as wrapping is made with CFFI
currently only HTML output and limited number of cmark’s options are supported (CMARK_OPT_SAFE, CMARK_OPT_NOBREAKS, CMARK_OPT_HARDBREAKS)
Examples
>>> from paka import cmark
Render with CMARK_OPT_DEFAULT | CMARK_OPT_NOBREAKS (unlike cmark, paka.cmark uses CMARK_OPT_NOBREAKS by default):
>>> print(cmark.to_html(u"Hello,\n*World*!"))
<p>Hello, <em>World</em>!</p>
Render with CMARK_OPT_DEFAULT | CMARK_OPT_NOBREAKS | CMARK_OPT_SAFE:
>>> print(cmark.to_html(u"<p>nope</p>", safe=True))
<!-- raw HTML omitted -->
Render with CMARK_OPT_DEFAULT:
>>> print(cmark.to_html(u"Hello,\n*World*!", breaks=True))
<p>Hello,
<em>World</em>!</p>
Render with CMARK_OPT_DEFAULT | CMARK_OPT_HARDBREAKS:
>>> print(cmark.to_html(u"Hello,\n*World*!", breaks="hard"))
<p>Hello,<br />
<em>World</em>!</p>
Installation
Library is available on PyPI, you can use pip for installation:
$ pip install paka.cmark
Running tests
$ tox
Getting coverage
Collect info:
$ tox -e coverage
View HTML report:
$ sensible-browser .tox/coverage/tmp/cov_html/index.html
Checking code style
Run code checkers:
$ tox -e checks
Getting documentation
Build HTML docs:
$ tox -e docs
View built docs:
$ sensible-browser .tox/docs/tmp/docs_html/index.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.