Skip to main content

Python parser for the CommonMark Markdown spec

Project description

Pure Python port of jgm’s stmd.js, a Markdown parser and renderer for the CommonMark 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 stmd.js.

We are currently at the same development stage (actually a bit ahead because we have implemented HTML entity conversion and href URL escaping) as stmd.js. (Although 1 test fails on 3.3 and 2 on 2.7 due to HTML entity conversion)

Current version: 0.5.0

Build Status

Installation

rolands@kamaji:~$ pip install commonmark

Usage

from CommonMark import CommonMark
parser = CommonMark.DocParser()
renderer = CommonMark.HTMLRenderer()
print(renderer.render(parser.parse("Hello *World*")))

----- or -----

rolands@kamaji:~$ CommonMark.py README.md -o README.html
rolands@kamaji:~$ CommonMark.py -h

Tests

The tests script, CommonMark-tests.py, is pretty much a devtool. As well as running all the tests embeded 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 inputing a line with just end, to quit do the same but with quit). -d can be used to print call tracing.

rolands@kamaji:~/utils/CommonMark-py$ python CommonMark-tests.py -h
usage: CommonMark-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 seperated 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CommonMark-0.5.0.tar.gz (49.2 kB view details)

Uploaded Source

File details

Details for the file CommonMark-0.5.0.tar.gz.

File metadata

  • Download URL: CommonMark-0.5.0.tar.gz
  • Upload date:
  • Size: 49.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for CommonMark-0.5.0.tar.gz
Algorithm Hash digest
SHA256 ac9b2a01e5dd3f18aff0c1d045ab79b4d7bdcba24d1af5b3dccae405c43d255f
MD5 43c9062122de5b2864f394f8e3764502
BLAKE2b-256 1e19fb900b116432a897c082d2d72dab4d37d322fb2bf5697b8133137d48d1ad

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page