Skip to main content

Python-Markdown extension: priority badges from !level inline keywords and ! / !! task-list shorthand

Project description

markdown-priority-badges

A Python-Markdown extension that renders priority badges two ways: !level keywords inline anywhere, and a ! / !! shorthand on task-list items. Works in Zensical, MkDocs, or plain Python-Markdown. The badge ships its own inline styles, so no external CSS is required.

Why?

This is not a replacement for admonitions / callouts (!!! warning, > [!NOTE]). Those wrap a block of explanatory text. Priority badges are the opposite: tiny inline pills you can drop anywhere, but that fit especially nicely into a list item, todo, or table cell, so priority is scannable at a glance without turning the line into a block. The intended usage is exactly that split: reach for a callout when you have a paragraph to say, and reach for a badge to mark some rows.

Inline keywords

Inline !level keywords (!low / !medium / !high / !critical) work anywhere (prose, headings, table cells):

This migration is !critical and blocks the release.

## !high Rotate the keys

Inline priority badges rendered in prose and a heading

Only the configured level keywords match, so an ordinary !, !important, or !highest in text is never touched.

Todo shorthand

Inside a checkbox item, ! = high and !! = critical, a quick shorthand for !high / !critical. The explicit !level keywords (including custom ones like !todo) work in list items too, so a todo list can mix all of them:

- [ ] !blocker Waiting on vendor API access
- [ ] !! Ship the security patch today
- [ ] ! Review the migration PR
- [ ] !medium Update the runbook
- [ ] !low Tidy up log formatting
- [x] !! Rotate the leaked credentials
- [ ] Weekly backup check
Todo list with priority badges

The shorthand marker must come first (right after the checkbox) and be followed by a space, so - [ ] !important note is left untouched. Works with -, *, + bullets and both [ ] / [x] states.

Levels

Four built-in levels, plus any custom level you add via config (blocker below is an example):

Level Origin Keyword Renders as
Low built-in !low low
Medium built-in !medium medium
High built-in !high high
Critical built-in !critical critical
Blocker example custom !blocker blocker
Todo example custom !todo todo

The default backgrounds are low green, medium amber, high orange, critical red. The ! / !! task-list shorthand always maps to high / critical; lower levels are used via their inline keyword (!low, !medium). Badge text color (black or white) is chosen automatically for legibility against each background.

Custom / extra levels

The levels option is a name → color map that is merged over the built-ins, so you can recolor a level or add your own:

# zensical.toml
[project.markdown_extensions.markdown_priority_badges.levels]
blocker = "#7b1fa2"  # a new purple level, used as !blocker
todo    = "#1565c0"  # a new blue level, used as !todo
low     = "#1b5e20"  # recolor a built-in
# plain Python-Markdown
from markdown_priority_badges import PriorityBadgesExtension
markdown.markdown(text, extensions=["pymdownx.tasklist", PriorityBadgesExtension(levels={"blocker": "#7b1fa2"})])

Colors may be 3- or 6-digit hex (#7b1fa2, #eee) or a common CSS name (red, yellow, rebeccapurple); the badge text color auto-contrasts against them.

Install & enable

uv add markdown-priority-badges

(or pip install markdown-priority-badges)

Zensical (zensical.toml):

[project.markdown_extensions.markdown_priority_badges]

Plain Python-Markdown:

markdown.markdown(text, extensions=["pymdownx.tasklist", "markdown_priority_badges"])

The badge renders as <span class="task-prio task-prio--<level>" style="...">...</span>. The task-prio classes are kept for optional site-side overriding, but no CSS is needed by default.

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_priority_badges-0.1.0.tar.gz (128.9 kB view details)

Uploaded Source

Built Distribution

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

markdown_priority_badges-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file markdown_priority_badges-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for markdown_priority_badges-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34e6088a2811af12dafecc0b31eb9a9894e3f5efa8b51034af612738746dd303
MD5 2a24a1e0bd4dd9b73926e7075172bed4
BLAKE2b-256 74a4eb9216f317d9000c0cb813b79d0e5e4a959372090abf7788b95868e66f7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdown_priority_badges-0.1.0.tar.gz:

Publisher: publish.yml on antoinekh/markdown-priority-badges

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

File details

Details for the file markdown_priority_badges-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for markdown_priority_badges-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e699aeda0027f8aa75339fb287d1a9f960082eaf38d3ecc420e3ab4fb222e0a3
MD5 c3a47dcb5d4e6a72103858d5476ee6b0
BLAKE2b-256 8b867fc007038edce18322c5cc829b9a50e3fe83fe7fc886ca2690fc3840b192

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdown_priority_badges-0.1.0-py3-none-any.whl:

Publisher: publish.yml on antoinekh/markdown-priority-badges

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