mdformat-footnote

0.1.3 · active · verified Thu Apr 16

mdformat-footnote is a plugin for the opinionated Markdown formatter `mdformat`. It extends `mdformat` to properly parse, validate, and format Pandoc-style footnotes, ensuring consistent styling within Markdown documents. The current version is 0.1.3, and releases are tied to supporting new `mdformat` versions or addressing specific formatting issues.

Common errors

Warnings

Install

Imports

Quickstart

To use `mdformat-footnote`, you need to install both `mdformat` and `mdformat-footnote`. Then, when using `mdformat` (either via the Python API or CLI), you must explicitly enable the 'footnote' extension.

import mdformat

markdown_with_footnotes = (
    """
Here is a footnote reference.[^1]

And here's a longer one.[^bignote]

[^1]: This is the first footnote.
[^bignote]: Here's one with multiple paragraphs and code.
    
    Subsequent paragraphs are indented to show that they belong to the previous footnote.
"""
)

# Using the Python API to format with the footnote extension
formatted_markdown = mdformat.text(markdown_with_footnotes, extensions={'footnote'})

print("--- Original ---")
print(markdown_with_footnotes)
print("\n--- Formatted ---")
print(formatted_markdown)

# To use via CLI (assuming mdformat and mdformat-footnote are installed):
# Save the above markdown to a file, e.g., 'input.md'
# Then run: mdformat --extensions footnote input.md

view raw JSON →