Skip to main content

Generate html from markdown with code-block highlighting

Project description

Build Status Azure DevOps coverage pre-commit.ci status

markdown-code-blocks

A stupid simple bit of code which combines mistune and pygments to convert markdown into html. Very similar to github markdown, but for python.

Installation

pip install markdown-code-blocks

Usage

The library provides a single function highlight which takes in a markdown string and returns html.

You can also use the cli markdown-code-blocks-highlight. It optionally takes a single filename (defaulting to stdin) and writes to stdout.

For example:

markdown-code-blocks-highlight f.md > f.htm

pygments css

I'd suggest grabbing a theme file from pygments-css (or any other provider of pygments themes -- if you google there's a bunch of them).

This library will use the class .highlight so be sure to change out whatever class the theme uses with that.

Most themes (for whatever reason) don't add styles for diff display. I usually do something like this:

.highlight .gi { color: #070; }
.highlight .gd { color: #911; }

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

markdown_code_blocks-3.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

markdown_code_blocks-3.1.0-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file markdown_code_blocks-3.1.0.tar.gz.

File metadata

  • Download URL: markdown_code_blocks-3.1.0.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for markdown_code_blocks-3.1.0.tar.gz
Algorithm Hash digest
SHA256 84669631a15d161dfe789296ecfbf9ddfd006041a062155ad45b9ea79abc970b
MD5 f7e71ddf72efcc2502371a34a8eb09af
BLAKE2b-256 204d66a081cfb1fdedf62410287a95bef2b2aaa91c066aeed0cf5441ea274d7a

See more details on using hashes here.

File details

Details for the file markdown_code_blocks-3.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: markdown_code_blocks-3.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10

File hashes

Hashes for markdown_code_blocks-3.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 77d877f0ebc9805635150a6195478f49e64f1df30b546b6cb2914724016d8482
MD5 07d028c6f3e294cf2d1f679f6954f290
BLAKE2b-256 bd5dbaa5c7a58f3738f586c7aba16c380fbbe031e27cc15eef30af17afee50d3

See more details on using hashes here.

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