Skip to main content

mdformat-obsidian

Build Status PyPI version

An mdformat plugin for Obsidian Flavored Markdown.

Features

  • Callouts - Alert-style blocks with custom titles and folding
    • Supports all standard callout types (note, tip, warning, etc.)
    • Custom callout types with any identifier
    • Foldable callouts with - or + indicators
    • Nested callouts
    • Case-insensitive type matching (normalized to uppercase for compatibility)
  • Inline Footnotes - Obsidian's ^[inline footnote] syntax
  • Task Lists - Extended checklist markers beyond [x] and [ ]
    • Supports [?], [/], [-], and other custom markers
    • Preserves marker style during formatting
  • Dollar Math - LaTeX math with $...$ and $$...$$ delimiters
    • Inline math: $E=mc^2$
    • Block math: $$\n...\n$$

[!NOTE] The format for GitHub Alerts differs slightly from Obsidian callouts. Obsidian supports folding, custom titles, and is case-insensitive. For improved interoperability, this package normalizes callout types to uppercase (e.g., [!tip][!TIP]).

mdformat Usage

Add this package wherever you use mdformat and the plugin will be auto-recognized. No additional configuration necessary. See additional information on mdformat plugins here

Tip: this package specifies an "extra" ('recommended') for plugins that work well with GFM:

pre-commit / prek

repos:
  - repo: https://github.com/executablebooks/mdformat
    rev: 1.0.0
    hooks:
      - id: mdformat
        additional_dependencies:
          - mdformat-obsidian
          # - "mdformat-obsidian[recommended]"

uvx

uvx --with=mdformat-obsidian mdformat

Or with pipx:

pipx install mdformat
pipx inject mdformat mdformat-obsidian

HTML Rendering

To generate HTML output, use obsidian_plugin from mdit_plugins. This combines all Obsidian-flavored markdown features (callouts, footnotes, task lists, math). For more details, see the markdown-it-py documentation.

from markdown_it import MarkdownIt
from mdformat_obsidian.mdit_plugins import obsidian_plugin

md = MarkdownIt()
md.use(obsidian_plugin)

text = "> [!tip] Callouts can have custom titles\n> Like this one."
md.render(text)
# <div>
# <div data-callout-metadata="" data-callout-fold="" data-callout="tip" class="callout">
# <div class="callout-title">
# <div class="callout-title-inner">Callouts can have custom titles</div>
# </div>
# <div class="callout-content">
# <p>Like this one.</p>
# </div>
# </div>
# </div>

Accessibility Note: For improved semantics, callouts are rendered as <div> elements rather than <blockquote>. The > syntax is repurposed for callouts (not quotations), so using div elements better represents the content structure. See discussion on GitHub.

Caveats

  • LaTeX Math: Direct \begin{...} LaTeX environments are not supported. Use dollar math syntax ($...$ or $$...$$) instead.
  • HTML Output Only: The HTML rendering features are designed for programmatic HTML generation. For markdown-to-markdown formatting (the primary mdformat use case), these renderers are not invoked.
  • GitHub Compatibility: While callouts work in both Obsidian and GitHub, subtle formatting differences exist. This plugin prioritizes Obsidian compatibility.

Contributing

See CONTRIBUTING.md

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdformat_obsidian-0.3.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

mdformat_obsidian-0.3.2-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file mdformat_obsidian-0.3.2.tar.gz.

File metadata

  • Download URL: mdformat_obsidian-0.3.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mdformat_obsidian-0.3.2.tar.gz
Algorithm Hash digest
SHA256 1de557e61c65f563152a0337a9645924d88648b7c5ca3f2d3379141f5b9732ec
MD5 54b5ffc65fd020d4a5295098dba67fa5
BLAKE2b-256 c9a1a0db8ddef56aa3b30b1ed323f5cce129cf7d50b345d6090ce3796465553a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdformat_obsidian-0.3.2.tar.gz:

Publisher: tests.yml on KyleKing/mdformat-obsidian

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_obsidian-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mdformat_obsidian-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f52ecde1ff36b7083e3f694086cbe00e11975dcaf0890f840a01eb572baa0063
MD5 f97f9ba977427b241f9037dca1a6a777
BLAKE2b-256 0a8f3e34eabc5751d18d4b9dae52f589f5ca4c1427c39acea509e905807cb148

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdformat_obsidian-0.3.2-py3-none-any.whl:

Publisher: tests.yml on KyleKing/mdformat-obsidian

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 Sentry Error logging StatusPage Status page