All Projects → kapyshin → paka.cmark

kapyshin / paka.cmark

Licence: BSD-3-Clause license
Lightweight CFFI-based Python bindings to cmark library (CommonMark implementation in C).

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
python
139335 projects - #7 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to paka.cmark

Markdown
CommonMark-compliant markdown parser and renderer in Go. This repository has moved to https://gitlab.com/golang-commonmark/markdown
Stars: ✭ 180 (+682.61%)
Mutual labels:  commonmark
Lute
🎼 一款对中文语境优化的 Markdown 引擎,支持 Go 和 JavaScript。A structured Markdown engine that supports Go and JavaScript.
Stars: ✭ 222 (+865.22%)
Mutual labels:  commonmark
motion-markdown-it
Ruby/RubyMotion version of Markdown-it (CommonMark compliant parser and extendable)
Stars: ✭ 42 (+82.61%)
Mutual labels:  commonmark
Vditor
♏ 一款浏览器端的 Markdown 编辑器,支持所见即所得(富文本)、即时渲染(类似 Typora)和分屏预览模式。An In-browser Markdown editor, support WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes.
Stars: ✭ 3,773 (+16304.35%)
Mutual labels:  commonmark
Commonmark.py
Python CommonMark parser
Stars: ✭ 215 (+834.78%)
Mutual labels:  commonmark
dss python
Native, "direct" Python bindings and misc tools for OpenDSS (EPRI Distribution System Simulator). Based on CFFI, DSS C-API and custom patches, aiming for full COM API-level compatibility on Windows, Linux and MacOS.
Stars: ✭ 31 (+34.78%)
Mutual labels:  cffi
Commonmark
Create, parse, and render Markdown text according to the CommonMark specification
Stars: ✭ 147 (+539.13%)
Mutual labels:  commonmark
markdown-toolbar
A clone of GitHub's markdown toolbar
Stars: ✭ 19 (-17.39%)
Mutual labels:  commonmark
Markdownlint
A Node.js style checker and lint tool for Markdown/CommonMark files.
Stars: ✭ 2,828 (+12195.65%)
Mutual labels:  commonmark
markdown
The first generation of Markdown rendering for R (born in 2012). Now R Markdown usually means the *r*markdown package instead of *markdown*. The repo for the former is at https://github.com/rstudio/rmarkdown
Stars: ✭ 64 (+178.26%)
Mutual labels:  commonmark
Markdownui
Render Markdown text in SwiftUI
Stars: ✭ 207 (+800%)
Mutual labels:  commonmark
Markdig
A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
Stars: ✭ 2,730 (+11769.57%)
Mutual labels:  commonmark
python-cffi-demo
Python CFFI demo: interfacing C++, Fortran, and Python.
Stars: ✭ 21 (-8.7%)
Mutual labels:  cffi
Tui.editor
🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
Stars: ✭ 14,016 (+60839.13%)
Mutual labels:  commonmark
markdig.wpf
A WPF library for xoofx/markdig https://github.com/xoofx/markdig
Stars: ✭ 133 (+478.26%)
Mutual labels:  commonmark
Commonmark
Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.
Stars: ✭ 2,128 (+9152.17%)
Mutual labels:  commonmark
cl-liballegro
Common Lisp bindings and interface to the Allegro 5 game programming library
Stars: ✭ 44 (+91.3%)
Mutual labels:  cffi
clj-pdf-markdown
Library for rendering markdown to clj-pdf data-structure syntax.
Stars: ✭ 20 (-13.04%)
Mutual labels:  commonmark
markdown-it-github-headings
Add anchors and links to headings just like Github does
Stars: ✭ 22 (-4.35%)
Mutual labels:  commonmark
koino
CommonMark + GFM compatible Markdown parser and renderer
Stars: ✭ 81 (+252.17%)
Mutual labels:  commonmark

paka.cmark

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

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.6 are supported
  • PyPy (Python 2.7) is supported, as wrapping is made with CFFI
  • no need to install libcmark, it is bundled with paka.cmark (and sources of the former are regularly updated according to upstream)
  • supported output: HTML, XML, CommonMark, man, LaTeX
  • supported options: CMARK_OPT_UNSAFE, CMARK_OPT_NOBREAKS, CMARK_OPT_HARDBREAKS, CMARK_OPT_SOURCEPOS, CMARK_OPT_SMART
  • unlike libcmark—underlying C library—paka.cmark uses CMARK_OPT_NOBREAKS by default (breaks argument allows to control line break rendering)
  • safe HTML output is on by default (like in libcmark)

Examples

>>> from paka import cmark

Render with CMARK_OPT_DEFAULT | CMARK_OPT_NOBREAKS:

>>> print(cmark.to_html(u"<p>nope</p>"))
<!-- raw HTML omitted -->

Render with CMARK_OPT_DEFAULT | CMARK_OPT_NOBREAKS | CMARK_OPT_UNSAFE:

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

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>

Render CommonMark with CMARK_OPT_DEFAULT | CMARK_OPT_NOBREAKS:

>>> print(cmark.to_commonmark(u"_Hello_"))
*Hello*

Installation

Library is available on PyPI, you can use pip for installation:

$ pip install paka.cmark

Getting documentation

Build HTML docs:

$ tox -e docs

View built docs:

$ sensible-browser .tox/docs/tmp/docs_html/index.html

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].