commonmark


Namecommonmark JSON
Version 0.9.1 PyPI version JSON
download
home_pagehttps://github.com/rtfd/commonmark.py
SummaryPython parser for the CommonMark Markdown spec
upload_time2019-10-04 15:37:39
maintainerNikolas Nyby
docs_urlNone
authorBibek Kafle <bkafle662@gmail.com>, Roland Shoemaker <rolandshoemaker@gmail.com>
requires_python
licenseBSD-3-Clause
keywords markup markdown commonmark
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rtfd/commonmark.py",
    "name": "commonmark",
    "maintainer": "Nikolas Nyby",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "nikolas@gnu.org",
    "keywords": "markup,markdown,commonmark",
    "author": "Bibek Kafle <bkafle662@gmail.com>, Roland Shoemaker <rolandshoemaker@gmail.com>",
    "author_email": "rolandshoemaker@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/60/48/a60f593447e8f0894ebb7f6e6c1f25dafc5e89c5879fdc9360ae93ff83f0/commonmark-0.9.1.tar.gz",
    "platform": "",
    "description": "commonmark.py\n=============\n\ncommonmark.py is a pure Python port of `jgm <https://github.com/jgm>`__'s\n`commonmark.js <https://github.com/jgm/commonmark.js>`__, a\nMarkdown parser and renderer for the\n`CommonMark <http://commonmark.org>`__ specification, using only native\nmodules. Once both this project and the CommonMark specification are\nstable we will release the first ``1.0`` version and attempt to keep up\nto date with changes in ``commonmark.js``.\n\ncommonmark.py is tested against the CommonMark spec with Python versions\n2.7, 3.4, 3.5, 3.6, and 3.7.\n\n**Current version:** 0.9.1\n\n|Pypi Link| |Build Status| |Doc Link|\n\nInstallation\n------------\n\n::\n\n    $ pip install commonmark\n\nUsage\n-----\n\n::\n\n    >>> import commonmark\n    >>> commonmark.commonmark('*hello!*')\n    '<p><em>hello!</em></p>\\n'\n\nOr, without the syntactic sugar:\n\n.. code:: python\n\n    import commonmark\n    parser = commonmark.Parser()\n    ast = parser.parse(\"Hello *World*\")\n\n    renderer = commonmark.HtmlRenderer()\n    html = renderer.render(ast)\n    print(html) # <p>Hello <em>World</em><p/>\n\n    # inspecting the abstract syntax tree\n    json = commonmark.dumpJSON(ast)\n    commonmark.dumpAST(ast) # pretty print generated AST structure\n\nThere is also a CLI:\n\n::\n\n    $ cmark README.md -o README.html\n    $ cmark README.md -o README.json -aj # output AST as JSON\n    $ cmark README.md -a # pretty print generated AST structure\n    $ cmark -h\n    usage: cmark [-h] [-o [O]] [-a] [-aj] [infile]\n\n    Process Markdown according to the CommonMark specification.\n\n    positional arguments:\n      infile      Input Markdown file to parse, defaults to stdin\n\n    optional arguments:\n      -h, --help  show this help message and exit\n      -o [O]      Output HTML/JSON file, defaults to stdout\n      -a          Print formatted AST\n      -aj         Output JSON AST\n\n\nContributing\n------------\n\nIf you would like to offer suggestions/optimizations/bugfixes through\npull requests please do! Also if you find an error in the\nparser/renderer that isn't caught by the current test suite please open\na new issue and I would also suggest you send the\n`commonmark.js <https://github.com/jgm/commonmark.js>`__ project\na pull request adding your test to the existing test suite.\n\nTests\n-----\n\nTo work on commonmark.py, you will need to be able to run the test suite to\nmake sure your changes don't break anything. To run the tests, you can do\nsomething like this:\n\n::\n\n   $ pyvenv venv\n   $ ./venv/bin/python setup.py develop test\n\nThe tests script, ``commonmark/tests/run_spec_tests.py``, is pretty much a devtool. As\nwell as running all the tests embedded in ``spec.txt`` it also allows you\nto run specific tests using the ``-t`` argument, provide information\nabout passed tests with ``-p``, percentage passed by category of test\nwith ``-s``, and enter markdown interactively with ``-i`` (In\ninteractive mode end a block by inputting a line with just ``end``, to\nquit do the same but with ``quit``). ``-d`` can be used to print call\ntracing.\n\n::\n\n    $ ./venv/bin/python commonmark/tests/run_spec_tests.py -h\n    usage: run_spec_tests.py [-h] [-t T] [-p] [-f] [-i] [-d] [-np] [-s]\n\n    script to run the CommonMark specification tests against the commonmark.py\n    parser.\n\n    optional arguments:\n      -h, --help  show this help message and exit\n      -t T        Single test to run or comma separated list of tests (-t 10 or -t 10,11,12,13)\n      -p          Print passed test information\n      -f          Print failed tests (during -np...)\n      -i          Interactive Markdown input mode\n      -d          Debug, trace calls\n      -np         Only print section header, tick, or cross\n      -s          Print percent of tests passed by category\n\nAuthors\n-------\n\n-  `Bibek Kafle <https://github.com/kafle>`__\n-  `Roland Shoemaker <https://github.com/rolandshoemaker>`__\n-  `Nikolas Nyby <https://github.com/nikolas>`__\n\n.. |Pypi Link| image:: https://img.shields.io/pypi/v/commonmark.svg\n   :target: https://pypi.org/project/commonmark/\n\n.. |Build Status| image:: https://travis-ci.org/rtfd/commonmark.py.svg?branch=master\n   :target: https://travis-ci.org/rtfd/commonmark.py\n\n.. |Doc Link| image:: https://readthedocs.org/projects/commonmarkpy/badge/?version=latest\n   :target: https://commonmarkpy.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n\n\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "Python parser for the CommonMark Markdown spec",
    "version": "0.9.1",
    "split_keywords": [
        "markup",
        "markdown",
        "commonmark"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "091b5c3805fbdad90d5658ad4bf47687",
                "sha256": "da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"
            },
            "downloads": -1,
            "filename": "commonmark-0.9.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "091b5c3805fbdad90d5658ad4bf47687",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 51068,
            "upload_time": "2019-10-04T15:37:37",
            "upload_time_iso_8601": "2019-10-04T15:37:37.674968Z",
            "url": "https://files.pythonhosted.org/packages/b1/92/dfd892312d822f36c55366118b95d914e5f16de11044a27cf10a7d71bbbf/commonmark-0.9.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "cd1dc70c4714d9ed4117a40490c25e00",
                "sha256": "452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"
            },
            "downloads": -1,
            "filename": "commonmark-0.9.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cd1dc70c4714d9ed4117a40490c25e00",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 95764,
            "upload_time": "2019-10-04T15:37:39",
            "upload_time_iso_8601": "2019-10-04T15:37:39.817349Z",
            "url": "https://files.pythonhosted.org/packages/60/48/a60f593447e8f0894ebb7f6e6c1f25dafc5e89c5879fdc9360ae93ff83f0/commonmark-0.9.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2019-10-04 15:37:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "rtfd",
    "github_project": "commonmark.py",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "commonmark"
}
        
Elapsed time: 0.01441s