1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
|
Metadata-Version: 2.1
Name: commonmark
Version: 0.9.1
Summary: Python parser for the CommonMark Markdown spec
Home-page: https://github.com/rtfd/commonmark.py
Author: Bibek Kafle <bkafle662@gmail.com>, Roland Shoemaker <rolandshoemaker@gmail.com>
Author-email: rolandshoemaker@gmail.com
Maintainer: Nikolas Nyby
Maintainer-email: nikolas@gnu.org
License: BSD-3-Clause
Description: 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.4, 3.5, 3.6, and 3.7.
**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
Keywords: markup,markdown,commonmark
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Other Environment
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Documentation
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup
Classifier: Topic :: Utilities
Description-Content-Type: text/x-rst
Provides-Extra: test
|