Mdformat plugin for Hugo-flavored Markdown
Project description
mdformat-hugo
Mdformat plugin for Hugo-flavored Markdown. Formats Hugo content files while preserving shortcodes and markdown attributes.
Features
This plugin adds support for Hugo-specific markdown syntax:
Shortcode Formatting
Hugo shortcodes are formatted with normalized whitespace.
Input:
{{< ref "documentation.md" >}}
{{% note %}}
Output:
{{< ref "documentation.md" >}}
{{% note %}}
Both {{< >}} (no markdown processing) and {{% %}} (markdown processed) shortcode styles are supported.
Markdown Attributes
Hugo extends standard Markdown with markdown attributes --
a syntax for attaching HTML attributes (IDs, classes, and key-value pairs) to rendered elements. Attributes are written
in curly braces after the element they modify, e.g., {#my-id .my-class key=value}.
This plugin normalizes attribute order and formatting:
- IDs (
#id) come first - Classes (
.class) follow, sorted alphabetically - Key-value pairs (
key=value) come last, sorted alphabetically by key - Values containing spaces or
=are quoted:key="hello world"; otherwise unquoted:key=value
Headings:
## Introduction {.zebra .apple #intro}
Formats to:
## Introduction {#intro .apple .zebra}
Images:
{width=300 .img-fluid height=200}
Formats to:
{.img-fluid height=200 width=300}
Code blocks:
```python {linenos=table .highlight #code}
def hello():
print("world")
```
Formats to:
```python {#code .highlight linenos=table}
def hello():
print("world")
```
Additional Features
This plugin bundles support for Hugo markdown features and code block formatting via dependencies:
Markdown syntax:
- mdformat-gfm - GFM tables, strikethrough, task lists, autolinks
- mdformat-front-matters - TOML/YAML/JSON frontmatter
- mdformat-gfm-alerts - Blockquote alerts (
[!NOTE],[!WARNING]) - mdformat-footnote - Pandoc-style footnotes
- mdformat-deflist - Definition lists
Code block formatting:
- mdformat-ruff - Format Python code blocks with ruff
- mdformat-shfmt - Format shell code blocks with shfmt
- mdformat-config - Format JSON, YAML, TOML code blocks
- mdformat-web - Format HTML, CSS, JavaScript code blocks
- mdformat-pyproject - Format pyproject.toml in code 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_hugo-0.1.0.tar.gz.
File metadata
- Download URL: mdformat_hugo-0.1.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1411d22eb917cf4d314b1e98b1e2056d5a228c7df72de1364883898dbefbced7
|
|
| MD5 |
7481cbce59a9cc3ed166ae82181f0960
|
|
| BLAKE2b-256 |
8f134708686e62223ef4e4041a6c8fc022c1370451d613f9c142b8b2b58a2aa4
|
Provenance
The following attestation bundles were made for mdformat_hugo-0.1.0.tar.gz:
Publisher:
release.yaml on gaborbernat/mdformat-hugo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdformat_hugo-0.1.0.tar.gz -
Subject digest:
1411d22eb917cf4d314b1e98b1e2056d5a228c7df72de1364883898dbefbced7 - Sigstore transparency entry: 948473836
- Sigstore integration time:
-
Permalink:
gaborbernat/mdformat-hugo@9f880b712e701609597e17dc716aff1e917edca5 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/gaborbernat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9f880b712e701609597e17dc716aff1e917edca5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mdformat_hugo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mdformat_hugo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efe6d8bf76287e4e0ae3cd21e1e114bc02713ca62dacf0fa338d64ef6d8a6a3c
|
|
| MD5 |
b9d4ed98592c2ae56cd3e3a9717e0fb2
|
|
| BLAKE2b-256 |
c50226a0f8b46439a7decc7e9a73c4bc6d912e03b2e34b305b1f520348581d94
|
Provenance
The following attestation bundles were made for mdformat_hugo-0.1.0-py3-none-any.whl:
Publisher:
release.yaml on gaborbernat/mdformat-hugo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdformat_hugo-0.1.0-py3-none-any.whl -
Subject digest:
efe6d8bf76287e4e0ae3cd21e1e114bc02713ca62dacf0fa338d64ef6d8a6a3c - Sigstore transparency entry: 948473893
- Sigstore integration time:
-
Permalink:
gaborbernat/mdformat-hugo@9f880b712e701609597e17dc716aff1e917edca5 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/gaborbernat
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@9f880b712e701609597e17dc716aff1e917edca5 -
Trigger Event:
push
-
Statement type: