All Projects → readthedocs → Commonmark.py

readthedocs / Commonmark.py

Licence: other
Python CommonMark parser

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Commonmark.py

Commonmark Highlighter
Highlight code blocks with league/commonmark
Stars: ✭ 106 (-50.7%)
Mutual labels:  commonmark
Down
Blazing fast Markdown / CommonMark rendering in Swift, built upon cmark.
Stars: ✭ 1,895 (+781.4%)
Mutual labels:  commonmark
Tui.editor
🍞📝 Markdown WYSIWYG Editor. GFM Standard + Chart & UML Extensible.
Stars: ✭ 14,016 (+6419.07%)
Mutual labels:  commonmark
Flexmark Java
CommonMark/Markdown Java parser with source level AST. CommonMark 0.28, emulation of: pegdown, kramdown, markdown.pl, MultiMarkdown. With HTML to MD, MD to PDF, MD to DOCX conversion modules.
Stars: ✭ 1,673 (+678.14%)
Mutual labels:  commonmark
Mdme
Self-rendering Markdown content
Stars: ✭ 140 (-34.88%)
Mutual labels:  commonmark
Markdown It
Markdown parser, done right. 100% CommonMark support, extensions, syntax plugins & high speed
Stars: ✭ 12,638 (+5778.14%)
Mutual labels:  commonmark
Html To Markdown
Convert HTML to Markdown with PHP
Stars: ✭ 1,293 (+501.4%)
Mutual labels:  commonmark
Lute
🎼 一款结构化的 Markdown 引擎,支持 Go 和 JavaScript。
Stars: ✭ 211 (-1.86%)
Mutual labels:  commonmark
Texme
Self-rendering Markdown + LaTeX documents
Stars: ✭ 1,970 (+816.28%)
Mutual labels:  commonmark
Markdown
CommonMark-compliant markdown parser and renderer in Go. This repository has moved to https://gitlab.com/golang-commonmark/markdown
Stars: ✭ 180 (-16.28%)
Mutual labels:  commonmark
Commonmark Java
Java library for parsing and rendering CommonMark (Markdown)
Stars: ✭ 1,675 (+679.07%)
Mutual labels:  commonmark
Editor.md
The open source embeddable online markdown editor (component).
Stars: ✭ 11,741 (+5360.93%)
Mutual labels:  commonmark
Commonmark
Create, parse, and render Markdown text according to the CommonMark specification
Stars: ✭ 147 (-31.63%)
Mutual labels:  commonmark
Goldmark
🏆 A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
Stars: ✭ 1,813 (+743.26%)
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 (+1654.88%)
Mutual labels:  commonmark
Elm Markdown
Pure Elm markdown parsing and rendering
Stars: ✭ 96 (-55.35%)
Mutual labels:  commonmark
Vditor
♏ 一款浏览器端的 Markdown 编辑器。
Stars: ✭ 1,742 (+710.23%)
Mutual labels:  commonmark
Markdig
A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
Stars: ✭ 2,730 (+1169.77%)
Mutual labels:  commonmark
Markdownui
Render Markdown text in SwiftUI
Stars: ✭ 207 (-3.72%)
Mutual labels:  commonmark
Commonmark
Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.
Stars: ✭ 2,128 (+889.77%)
Mutual labels:  commonmark

commonmark.py

commonmark.py is a pure Python port of jgm <https://github.com/jgm>'s commonmark.js <https://github.com/jgm/commonmark.js>, a Markdown parser and renderer for the CommonMark <http://commonmark.org>__ specification, using only native modules. Once both this project and the CommonMark specification are stable we will release the first 1.0 version and attempt to keep up to date with changes in commonmark.js.

commonmark.py is tested against the CommonMark spec with Python versions 2.7, 3.5, 3.6, 3.7, and 3.8.

Current version: 0.9.1

|Pypi Link| |Build Status| |Doc Link|

Installation

::

$ pip install commonmark

Usage

::

>>> import commonmark
>>> commonmark.commonmark('*hello!*')
'<p><em>hello!</em></p>\n'

Or, without the syntactic sugar:

.. code:: python

import commonmark
parser = commonmark.Parser()
ast = parser.parse("Hello *World*")

renderer = commonmark.HtmlRenderer()
html = renderer.render(ast)
print(html) # <p>Hello <em>World</em><p/>

# inspecting the abstract syntax tree
json = commonmark.dumpJSON(ast)
commonmark.dumpAST(ast) # pretty print generated AST structure

There is also a CLI:

::

$ cmark README.md -o README.html
$ cmark README.md -o README.json -aj # output AST as JSON
$ cmark README.md -a # pretty print generated AST structure
$ cmark -h
usage: cmark [-h] [-o [O]] [-a] [-aj] [infile]

Process Markdown according to the CommonMark specification.

positional arguments:
  infile      Input Markdown file to parse, defaults to stdin

optional arguments:
  -h, --help  show this help message and exit
  -o [O]      Output HTML/JSON file, defaults to stdout
  -a          Print formatted AST
  -aj         Output JSON AST

Contributing

If you would like to offer suggestions/optimizations/bugfixes through pull requests please do! Also if you find an error in the parser/renderer that isn't caught by the current test suite please open a new issue and I would also suggest you send the commonmark.js <https://github.com/jgm/commonmark.js>__ project a pull request adding your test to the existing test suite.

Tests

To work on commonmark.py, you will need to be able to run the test suite to make sure your changes don't break anything. To run the tests, you can do something like this:

::

$ pyvenv venv $ ./venv/bin/python setup.py develop test

The tests script, commonmark/tests/run_spec_tests.py, is pretty much a devtool. As well as running all the tests embedded in spec.txt it also allows you to run specific tests using the -t argument, provide information about passed tests with -p, percentage passed by category of test with -s, and enter markdown interactively with -i (In interactive mode end a block by inputting a line with just end, to quit do the same but with quit). -d can be used to print call tracing.

::

$ ./venv/bin/python commonmark/tests/run_spec_tests.py -h
usage: run_spec_tests.py [-h] [-t T] [-p] [-f] [-i] [-d] [-np] [-s]

script to run the CommonMark specification tests against the commonmark.py
parser.

optional arguments:
  -h, --help  show this help message and exit
  -t T        Single test to run or comma separated list of tests (-t 10 or -t 10,11,12,13)
  -p          Print passed test information
  -f          Print failed tests (during -np...)
  -i          Interactive Markdown input mode
  -d          Debug, trace calls
  -np         Only print section header, tick, or cross
  -s          Print percent of tests passed by category

Authors

  • Bibek Kafle <https://github.com/kafle>__
  • Roland Shoemaker <https://github.com/rolandshoemaker>__
  • Nikolas Nyby <https://github.com/nikolas>__

.. |Pypi Link| image:: https://img.shields.io/pypi/v/commonmark.svg :target: https://pypi.org/project/commonmark/

.. |Build Status| image:: https://travis-ci.org/rtfd/commonmark.py.svg?branch=master :target: https://travis-ci.org/rtfd/commonmark.py

.. |Doc Link| image:: https://readthedocs.org/projects/commonmarkpy/badge/?version=latest :target: https://commonmarkpy.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

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].