fletcher / MultiMarkdown-4

This project is now deprecated. Please use MultiMarkdown-6 instead!
https://github.com/fletcher/MultiMarkdown-5
Other
306 stars 59 forks source link

Extend definition lists to support admonitions #126

Open toonetown opened 9 years ago

toonetown commented 9 years ago

This PR allows you to define an admonition by using the syntax found at https://pythonhosted.org/Markdown/extensions/admonition.html. The difference between this implementation and the one described on pythonhosted is this implementation uses definition lists instead of nested paragraphs. Also, if you specify and empty string for the title, the generated <dt> element will still be generated, but will be empty.

The added classes are admonition and xxx - whatever you set the admonition as.

Also, if you do not provide a term, then Xxx will be used as the term. The first letter will be capitalized, and any underscores will be replaced with spaces. This allows you to define, for example:

!!!my_note
     This is my note

And it will be turned into:

<dl class="admonition my_note">
    <dt>My note</dt>
    <dd>This is my note</dd>
</dl>

If you define a term after the admonition annotation, then the term is used instead (without the admonition). So, for example:

!!! warning "Be Careful" !!!
:   This is a dangerous thing to do

Will be turned into:

<dl class="admonition warning">
    <dt>Be Careful</dt>
    <dd>This is a dangerous thing to do</dd>
</dl>

Note that the trailing triple exclamation point is optional, but can be used (similar to the # for headers) to balance out the way the line looks.

Non-HTML formats will just output their information as a definition list.

There are also unit tests added to the MarkdownTest repository (see https://github.com/fletcher/MMD-Test-Suite/pull/7)

toonetown commented 9 years ago

If this feature is still not desired (as mentioned by @fletcher in issue #125), feel free to just close the PR (and also MMD-Test-Suite#7).