Skip to main content

ChromaMark for Python — render and build colored blocks, pills, collapsibles, fields, meters and inline diff on top of Markdown, with Jupyter display.

Project description

chromamark (Python)

Render and build ChromaMark from Python — colored blocks, pills, collapsible sections, fields, meters, and inline diff on top of Markdown (CommonMark + GFM). Produces the same HTML as the JS renderer, so the same theme applies, and it displays inline in Jupyter.

Built on markdown-it-py.

Install

pip install chromamark

Render

from chromamark import render, create_renderer

html = render("::: success\nAll good [!ok pass]\n:::")

# or as a markdown-it-py plugin:
from markdown_it import MarkdownIt
from chromamark import chromamark_plugin
md = MarkdownIt("commonmark").use(chromamark_plugin)

Build (fluent, for agent reports)

from chromamark import ChromaDoc

doc = ChromaDoc()
doc.heading("Deploy report")
doc.success("Deploy succeeded", "3/3 replicas healthy")
doc.fields(Region="eastus", Status=doc.pill("ok", "healthy"))
doc.table(["Stage", "Result"], [["unit", doc.pill("pass", "247")]])
print(doc.to_cm())     # ChromaMark source
print(doc.to_html())   # rendered HTML

Jupyter

from chromamark import display_chromamark
display_chromamark("::: success\nRun complete [=success 100%]\n:::")

ChromaDoc also renders itself in notebooks via _repr_html_.

A runnable, pre-executed example notebook lives at examples/chromamark_report.ipynb — it builds a model-evaluation report (colored block, pills, meters, fields, a table, and a collapsible) from computed results.

Parity with the JavaScript renderer

chromamark produces byte-identical HTML to @chromamark/renderer for normal content — verified by a differential harness over ~140,000 inputs (every ChromaMark construct, GFM, linkify, and the full SPEC/demo documents all match exactly). Three exotic edge cases differ, all involving unusual whitespace or non-BMP characters; none affect typical agent-generated reports:

  • Non-ASCII whitespace at a block edge (e.g. a leading U+3000 ideographic space): JS markdown-it preserves it (asciiTrim); markdown-it-py strips all Unicode whitespace. Upstream base-engine difference.
  • Six control/format code points inside ChromaMark constructs (U+001C–U+001F, U+0085 NEL, U+FEFF BOM): counted as whitespace by one engine's regex/strip but not the other, which can flip pill/field parsing.
  • Astral-plane (emoji) domain labels in bare links (e.g. 🎉.com): auto-linked by JS linkify-it but not linkify-it-py. BMP and IDN letter hosts match.

Credits

Inline change-tracking syntax is adopted from CriticMarkup (© 2013 Gabe Weatherhead & Erik Hess, Apache-2.0); ChromaMark's parser is an original, independent implementation. See the main README for full credits.

License

Modified MIT License with a SaaS source-availability provision — see LICENSE.md.

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

chromamark-0.1.2.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

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

chromamark-0.1.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file chromamark-0.1.2.tar.gz.

File metadata

  • Download URL: chromamark-0.1.2.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chromamark-0.1.2.tar.gz
Algorithm Hash digest
SHA256 37f188fdc5d2831a23e5100393ccf24f628893713a0f5a709adb290941eeaddf
MD5 eb5678f5af3448cd6b2bc1513e1f6639
BLAKE2b-256 fdf9f432cdf6edd5b489ac7d5d77ef1e59d06fc7564e7dff3f78ded5c01ea55d

See more details on using hashes here.

Provenance

The following attestation bundles were made for chromamark-0.1.2.tar.gz:

Publisher: publish.yml on cjfravel-dev/ChromaMark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chromamark-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: chromamark-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chromamark-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f5b303295d0427844d9970580eba43d860530293966f4d8e7ba8bb82745fa09e
MD5 7f24e6adb77a345cb8a3996181636de1
BLAKE2b-256 4bef1261a1c83db945fdbbcaae84b8d5ea9d7532c5ba13c432d3ca232c933f56

See more details on using hashes here.

Provenance

The following attestation bundles were made for chromamark-0.1.2-py3-none-any.whl:

Publisher: publish.yml on cjfravel-dev/ChromaMark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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