Skip to content

Heading tag should not be used as title of the blocks/admonitions #43

@amimas

Description

@amimas

The plugin currently generates an html code where the title of the special notes/admonitions are given an html heading h5.

return `
<div class="admonition admonition-${token.admonition}">
<div class="admonition-heading">
<h5>${iconTemplate} ${token.title || token.admonition}</h5>
</div>
<div class="admonition-content">
`;

This is an issue from both semantics and accessibility aspect. If I have the following structure in my markdown:

# My page/document title

## Section heading

Some introduction about this heading and here's a special note:

:::caution Something to keep in mind
some text here
:::

...

The above will produce the following hierarchy when the html page is generated:

h1 My page/document title

h2 Section heading

Some introduction about this heading and here's a special note:

h5 Something to keep in mind
some text here
...

Semantically that's inaccurate because after h2, the next sub-heading should be h3. For the same reason, it also fails the accessibility tests in Google's Lighthouse audit.

I think this plugin should not use h5 as the title of the notes. It can probably use a span (or something more appropriate) with a classname and then adjust the font size accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions