Skip to main content

Very lightweight CFFI-based Python bindings to cmark library (CommonMark implementation in C).

Project description

https://travis-ci.org/PavloKapyshin/paka.cmark.svg?branch=master

paka.cmark is a Python library that wraps subset of cmark C library. Wrapping is made with CFFI, so PyPy is supported in addition to CPython. Currently only HTML output and limited number of cmark’s options are supported (CMARK_OPT_SAFE and CMARK_OPT_NOBREAKS).

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("Hello,\n*World*!"))
<p>Hello, <em>World</em>!</p>

Render with CMARK_OPT_DEFAULT | CMARK_OPT_NOBREAKS | CMARK_OPT_SAFE:

>>> print(cmark.to_html("<p>nope</p>", safe=True))
<!-- raw HTML omitted -->

Render with CMARK_OPT_DEFAULT:

>>> print(cmark.to_html("Hello,\n*World*!", breaks=True))
<p>Hello,
<em>World</em>!</p>

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paka.cmark-1.9.1.tar.gz (96.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page