Mdformat plugin for Zola-flavored Markdown
Project description
mdformat-zola
Mdformat plugin for Zola-flavored Markdown. It formats Zola content files while keeping shortcodes, heading anchors, and code-block annotations intact.
Plain mdformat mangles Zola content. It reflows shortcode bodies (a Mermaid diagram becomes one escaped line), escapes
the * in {{/* … */}}, and wraps long inline shortcodes mid-call. This plugin adds Zola's syntax to mdformat so those
constructs round-trip.
Zola syntax
Each construct below gets one stable form. Where Zola treats ordering as insignificant, the plugin sorts.
Shortcodes
The plugin normalizes inline shortcodes {{ name(args) }} and their escaped form {{/* name(args) */}}: it collapses
whitespace, sorts arguments by name, and settles on one quote style. It does not wrap or escape them.
Input:
{{ youtube( autoplay=true , id="dQw4w9WgXcQ" ) }}
Output:
{{ youtube(autoplay=true, id="dQw4w9WgXcQ") }}
Body shortcodes {% name(args) %} … {% end %} (and the escaped {%/* … */%}) get the same treatment on their opening
tag. A raw body such as a Mermaid diagram stays byte-for-byte:
{% mermaid() %}
graph TD
A["velodex[x]"] --> B[*]
{% end %}
The body of a prose shortcode is Markdown that Zola re-renders, so the plugin formats it. By default this applies to
admonition, aside, callout, caution, details, important, note, quote, tip, and warning; every other
shortcode keeps its body verbatim. Point the plugin at your own set with the markdown_shortcodes option, on the CLI or
in .mdformat.toml:
mdformat --zola-markdown-shortcodes quote,note,sidebar content/
# .mdformat.toml
[plugin.zola]
markdown_shortcodes = ["quote", "note", "sidebar"]
Pass an empty value to keep every body verbatim.
Heading anchors
Zola lets you pin a heading's id and classes with a
{#id .class} suffix. The plugin puts the id first, then the classes in alphabetical order:
## Introduction {.lead #intro}
Formats to:
## Introduction {#intro .lead}
Code-block annotations
The plugin reorders Zola's
syntax-highlighting annotations to a fixed
sequence (linenos, linenostart, hl_lines, hide_lines, name), normalizes their whitespace, and keeps unknown
annotations:
```rust, hl_lines=3-4 8-9,linenos , linenostart=10
Formats to:
```rust,linenos,linenostart=10,hl_lines=3-4 8-9
Internal links such as [text](@/pages/about.md#anchor) survive as ordinary links, no special handling needed.
Bundled features
Installing the plugin pulls in the mdformat plugins that cover the rest of Zola's Markdown flavor (GitHub-Flavored
Markdown with footnotes, definition lists, alerts, and TOML +++ frontmatter), plus code formatters for fenced blocks:
Markdown syntax:
- mdformat-gfm - tables, strikethrough, task lists, autolinks
- mdformat-front-matters - TOML/YAML/JSON frontmatter
- mdformat-gfm-alerts - blockquote alerts (
[!NOTE],[!WARNING]) - mdformat-footnote - footnotes
- mdformat-deflist - definition lists
Code-block formatting:
- mdformat-ruff - Python blocks with ruff
- mdformat-shfmt - shell blocks with shfmt
- mdformat-config - JSON, YAML, TOML blocks
- mdformat-web - HTML, CSS, JavaScript blocks
- mdformat-pyproject - pyproject.toml blocks
Usage
mdformat content/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mdformat_zola-1.0.0.tar.gz.
File metadata
- Download URL: mdformat_zola-1.0.0.tar.gz
- Upload date:
- Size: 21.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6db4f8e2b1e51ff88db6c7fa84d11664ff2c4fb352a139439d29005ade4736d
|
|
| MD5 |
69ed7e9e30069528b43f6429d63161bc
|
|
| BLAKE2b-256 |
156a26ab37dd54e8f48c0379d0d4d49e85968e409e4c4b126bbd14a30c7010ad
|
Provenance
The following attestation bundles were made for mdformat_zola-1.0.0.tar.gz:
Publisher:
release.yaml on tox-dev/mdformat-zola
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdformat_zola-1.0.0.tar.gz -
Subject digest:
c6db4f8e2b1e51ff88db6c7fa84d11664ff2c4fb352a139439d29005ade4736d - Sigstore transparency entry: 2063530999
- Sigstore integration time:
-
Permalink:
tox-dev/mdformat-zola@d545cdfc49a305e173d520a8011c095d0563ee1b -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/tox-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@d545cdfc49a305e173d520a8011c095d0563ee1b -
Trigger Event:
push
-
Statement type:
File details
Details for the file mdformat_zola-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mdformat_zola-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32808ba2b708dc288d9a4ba9628e78e889d0a8ed52d3c7e5223c6229c9b0483f
|
|
| MD5 |
62d30977c3e67684fdd7933d6a8a8464
|
|
| BLAKE2b-256 |
432a119bb8a0f42b85bf341b7da34284da4a561a2342f5517ecfd761b145314c
|
Provenance
The following attestation bundles were made for mdformat_zola-1.0.0-py3-none-any.whl:
Publisher:
release.yaml on tox-dev/mdformat-zola
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdformat_zola-1.0.0-py3-none-any.whl -
Subject digest:
32808ba2b708dc288d9a4ba9628e78e889d0a8ed52d3c7e5223c6229c9b0483f - Sigstore transparency entry: 2063531012
- Sigstore integration time:
-
Permalink:
tox-dev/mdformat-zola@d545cdfc49a305e173d520a8011c095d0563ee1b -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/tox-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@d545cdfc49a305e173d520a8011c095d0563ee1b -
Trigger Event:
push
-
Statement type: