Metadata-Version: 2.4
Name: mdformat-hugo
Version: 0.1.0
Summary: Mdformat plugin for Hugo-flavored Markdown
Project-URL: Documentation, https://mdformat-hugo.readthedocs.io
Project-URL: Homepage, https://github.com/gaborbernat/mdformat-hugo
Project-URL: Source, https://github.com/gaborbernat/mdformat-hugo
Project-URL: Tracker, https://github.com/gaborbernat/mdformat-hugo/issues
Maintainer-email: Bernát Gábor <gaborjbernat@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Bernát Gábor
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: formatter,hugo,markdown,mdformat
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: markdown-it-py>=3
Requires-Dist: mdformat-config>=0.1.3
Requires-Dist: mdformat-deflist>=0.1.2
Requires-Dist: mdformat-footnote>=0.1.1
Requires-Dist: mdformat-front-matters>=2
Requires-Dist: mdformat-gfm-alerts>=1
Requires-Dist: mdformat-gfm>=1
Requires-Dist: mdformat-pyproject>=0.0.1
Requires-Dist: mdformat-ruff>=0.1.3
Requires-Dist: mdformat-shfmt>=0.1
Requires-Dist: mdformat-web>=0.1
Requires-Dist: mdformat>=0.7.17
Requires-Dist: mdit-py-plugins>=0.4
Description-Content-Type: text/markdown

# mdformat-hugo

[![PyPI](https://img.shields.io/pypi/v/mdformat-hugo?style=flat-square)](https://pypi.org/project/mdformat-hugo/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/mdformat-hugo.svg)](https://pypi.org/project/mdformat-hugo/)
[![check](https://github.com/gaborbernat/mdformat-hugo/actions/workflows/check.yaml/badge.svg)](https://github.com/gaborbernat/mdformat-hugo/actions/workflows/check.yaml)

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:**

```markdown
{{<  ref   "documentation.md"  >}}
{{%   note   %}}
```

**Output:**

```markdown
{{< ref "documentation.md" >}}
{{% note %}}
```

Both `{{< >}}` (no markdown processing) and `{{% %}}` (markdown processed) shortcode styles are supported.

### Markdown Attributes

Hugo extends standard Markdown with [markdown attributes](https://gohugo.io/content-management/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:

1. **IDs** (`#id`) come first
1. **Classes** (`.class`) follow, sorted alphabetically
1. **Key-value pairs** (`key=value`) come last, sorted alphabetically by key
1. Values containing spaces or `=` are quoted: `key="hello world"`; otherwise unquoted: `key=value`

**Headings:**

```markdown
## Introduction {.zebra .apple #intro}
```

Formats to:

```markdown
## Introduction {#intro .apple .zebra}
```

**Images:**

```markdown
![Logo](logo.png){width=300 .img-fluid height=200}
```

Formats to:

```markdown
![Logo](logo.png){.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](https://github.com/hukkin/mdformat-gfm) - GFM tables, strikethrough, task lists, autolinks
- [mdformat-front-matters](https://github.com/kyleking/mdformat-front-matters) - TOML/YAML/JSON frontmatter
- [mdformat-gfm-alerts](https://github.com/KyleKing/mdformat-gfm-alerts) - Blockquote alerts (`[!NOTE]`, `[!WARNING]`)
- [mdformat-footnote](https://github.com/executablebooks/mdformat-footnote) - Pandoc-style footnotes
- [mdformat-deflist](https://github.com/executablebooks/mdformat-deflist) - Definition lists

**Code block formatting:**

- [mdformat-ruff](https://github.com/Freed-Wu/mdformat-ruff) - Format Python code blocks with ruff
- [mdformat-shfmt](https://github.com/hukkin/mdformat-shfmt) - Format shell code blocks with shfmt
- [mdformat-config](https://github.com/hukkin/mdformat-config) - Format JSON, YAML, TOML code blocks
- [mdformat-web](https://github.com/hukkin/mdformat-web) - Format HTML, CSS, JavaScript code blocks
- [mdformat-pyproject](https://github.com/csala/mdformat-pyproject) - Format pyproject.toml in code blocks

## Usage

```bash
mdformat content/
```
