Skip to main content

Mdformat plugin for Hugo-flavored Markdown

Project description

mdformat-hugo

PyPI Supported Python versions check

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:

  1. IDs (#id) come first
  2. Classes (.class) follow, sorted alphabetically
  3. Key-value pairs (key=value) come last, sorted alphabetically by key
  4. 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:

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

Formats to:

![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:

Code block formatting:

Usage

mdformat content/

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

mdformat_hugo-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

mdformat_hugo-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

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

Hashes for mdformat_hugo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1411d22eb917cf4d314b1e98b1e2056d5a228c7df72de1364883898dbefbced7
MD5 7481cbce59a9cc3ed166ae82181f0960
BLAKE2b-256 8f134708686e62223ef4e4041a6c8fc022c1370451d613f9c142b8b2b58a2aa4

See more details on using hashes here.

Provenance

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

Publisher: release.yaml on gaborbernat/mdformat-hugo

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

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

Hashes for mdformat_hugo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efe6d8bf76287e4e0ae3cd21e1e114bc02713ca62dacf0fa338d64ef6d8a6a3c
MD5 b9d4ed98592c2ae56cd3e3a9717e0fb2
BLAKE2b-256 c50226a0f8b46439a7decc7e9a73c4bc6d912e03b2e34b305b1f520348581d94

See more details on using hashes here.

Provenance

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

Publisher: release.yaml on gaborbernat/mdformat-hugo

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