Skip to main content

Python bindings for MD4C

Project description

Release Status Test Status

PyMD4C

Python bindings (plus extras) for the very fast MD4C Markdown parsing and rendering library.

Overview

The MD4C C library provides a SAX-like parser that uses callbacks to return the various blocks, inlines, and text it parses from the Markdown input. In addition, it provides an HTML renderer built on top of the parser to provide HTML output directly.

PyMD4C provides Python bindings for both, plus some convenience features built on top. The goal is to provide a simple and fast interface for applications that just need to translate Markdown to HTML, while providing flexibility for applications that need to do more.

Brief installation instructions and examples are below, but see the full documentation for more detail.

Installation from PyPI

PyMD4C is available on PyPI under the name pymd4c. Install it with pip as you would any other Python package:

pip install pymd4c

This is the recommended method to obtain PyMD4C. It should work well on most Linux distributions, Windows, and macOS, but since it contains a C module, it must be built for each platform specifically. Those running on uncommon architectures or old versions of their OS may find that a prebuilt module isn't available. (If a build is not available or working for your platform and you think it should be, consider opening a GitHub issue.)

For more detailed installation instructions, including building from source (which should work on virtually any platform), see the "Installation" page in the full documentation.

Basic Usage

Once PyMD4C is installed, generating HTML from Markdown is as simple as the following:

import md4c

with open('README.md', 'r') as f:
    markdown = f.read()

renderer = md4c.HTMLRenderer()
html = renderer.parse(markdown)

This is just the most basic example to get you up and running ASAP. There are several options for customizing MD4C's parsing and HTML generation behavior, as well as other APIs for tasks other than generating HTML. The full documentation walks through all of those features.

Contributions

Thank you for your interest in contributing to PyMD4C! The "Contributing to PyMD4C" page in the documentation has some information that should prove helpful.

License

This project is licensed under the MIT license. See the LICENSE.md file for details.

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

pymd4c-1.1.1b3.tar.gz (31.2 kB view hashes)

Uploaded Source

Built Distributions

pymd4c-1.1.1b3-cp310-cp310-win_amd64.whl (89.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

pymd4c-1.1.1b3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (133.0 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pymd4c-1.1.1b3-cp310-cp310-macosx_10_14_x86_64.whl (31.0 kB view hashes)

Uploaded CPython 3.10 macOS 10.14+ x86-64

pymd4c-1.1.1b3-cp39-cp39-win_amd64.whl (89.1 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

pymd4c-1.1.1b3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (132.3 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pymd4c-1.1.1b3-cp39-cp39-macosx_10_14_x86_64.whl (31.0 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

pymd4c-1.1.1b3-cp38-cp38-win_amd64.whl (89.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

pymd4c-1.1.1b3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (134.5 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pymd4c-1.1.1b3-cp38-cp38-macosx_10_14_x86_64.whl (31.0 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pymd4c-1.1.1b3-cp37-cp37m-win_amd64.whl (89.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

pymd4c-1.1.1b3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (133.5 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

pymd4c-1.1.1b3-cp37-cp37m-macosx_10_14_x86_64.whl (31.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

pymd4c-1.1.1b3-cp36-cp36m-win_amd64.whl (89.0 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

pymd4c-1.1.1b3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (132.0 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

pymd4c-1.1.1b3-cp36-cp36m-macosx_10_14_x86_64.whl (31.0 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

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