COMMONMARK-PY(1) commonmark.py COMMONMARK-PY(1) (NAME) commonmark-py - commonmark.py [: ] [] : commonmark.py (deprecated). CommonMark markdown-it-py . . -- commonmark.py (pure Python) commonmark.js jgm Markdown CommonMark . CommonMark 1.0 commonmark.js . commonmark.py CommonMark 2.7 3.5 3.6 3.7 3.8 . : 0.9.2 [: PyPI] [] [: ] [] [: ] [] (INSTALLATION) $ pip install commonmark (USAGE) >>> import commonmark >>> commonmark.commonmark('*hello!*') '

hello!

\n' (syntactic sugar): import commonmark parser = commonmark.Parser() ast = parser.parse("Hello *World*") renderer = commonmark.HtmlRenderer() html = renderer.render(ast) print(html) #

Hello World

# inspecting the abstract syntax tree json = commonmark.dumpJSON(ast) commonmark.dumpAST(ast) # pretty print generated AST structure (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 pull request ! parser/renderer issue commonmark.js pull request . (TESTS) commonmark.py . : $ pyvenv venv $ ./venv/bin/python setup.py develop test commonmark/tests/run_spec_tests.py . spec.txt -t -p -s markdown -i ( end quit ). -d (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) o Bibek Kafle o Roland Shoemaker API HTML class commonmark.render.html.HtmlRenderer(options={}) out(s) . (override) . @param str {String} . tag(name, attrs=None, selfclosing=None) HTML. class commonmark.render.rst.ReStructuredTextRenderer(indent_char=' ') reStructuredText Markdown : import commonmark parser = commonmark.Parser() ast = parser.parse('Hello `inline code` example') renderer = commonmark.ReStructuredTextRenderer() rst = renderer.render(ast) print(rst) # Hello ``inline code`` example lit(s) . @param str {String} . Parser class commonmark.blocks.Parser(options={}) add_child(tag, offset) tag tip. tip . add_line() tip. tip -- . close_unmatched_blocks() . finalize(block, line_number) . string_content 'tight' 'loose' . tip . incorporate_line(ln) . markdown . parse(my_input) . AST . process_inlines(block) . class commonmark.node.NodeWalker(root) nxt() class commonmark.node.Node(node_type, sourcepos) (AUTHORS) Roland Shoemaker, Bibek Kafle (COPYRIGHT) 2014-2019, Roland Shoemaker, Bibek Kafle 0.9.2 May 30, 2026 COMMONMARK-PY(1)