Skip to content

Support Admonitions #309

@KyleKing

Description

@KyleKing

Describe the problem/need and solution

Problem

Right now, mdformat breaks indentation for admonitions. Below is a repeatable example based on the first snippet from the admonition documentation

~/Developer > pipx install mdformat-gfm --include-deps
  installed package mdformat-gfm 0.3.5, installed using Python 3.10.2
  These apps are now globally available
    - markdown-it
    - mdformat
done! ✨ 🌟 ✨
~/Developer > pbpaste > ad_test.md
~/Developer > bat ad_test.md
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: ad_test.md
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ !!! type "optional explicit title within double quotes"
   2   │     Any number of other indented markdown elements.
   3   │
   4   │     This is the second paragraph.
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
~/Developer > mdformat ad_test.md
~/Developer > bat ad_test.md
───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: ad_test.md
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ !!! type "optional explicit title within double quotes"
   2   │ Any number of other indented markdown elements.
   3   │
   4   │ ```
   5   │ This is the second paragraph.
   6   │ ```
───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Solution

admonitions are not part of the CommonMark specification and would be best handled by a plugin (i.e. mdformat-admonition)

I would be happy to try writing one, but I wanted to open an issue first so that I'm not duplicating effort. I saw that there was at least one other issue with admonition problems, but there didn't seem to be any updates since: #53 (#53 (comment))

Benefit

Would be nice to have support for admonitions (particular for mkdocs which uses the markdown extension)

Guide for implementation

No response

Tasks and updates

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpluginA plugin should be created or updated

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions