Skip to main content

build status 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; }

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.2.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markdown_code_blocks-3.2.0-py2.py3-none-any.whl (3.9 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: markdown_code_blocks-3.2.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for markdown_code_blocks-3.2.0.tar.gz
Algorithm Hash digest
SHA256 fa9c4de3b3655cff7fbb90daee50f5346f8998496402a3ade4ff4be8fac8166a
MD5 dba9ad37ae2d8bf3d885da918e1115e3
BLAKE2b-256 3bd0c0261f983f3216c0eed0048e0439cd7c9b29a1faf3e82fdb46da683659f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markdown_code_blocks-3.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c12a65c498453c8fab07000858dcaf4aa35d49dde62b183bbeefc91b06c355f6
MD5 e1eac8c736b0e80c266a1772fc68ecd6
BLAKE2b-256 fa996329f0d5ad66762b35e01169c2473c67a24c3e024fa7c09acfc09357ceba

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 files

3.1.0

2 files

3.0.0

2 files

2.1.0

2 files

2.0.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page