Consider option to demote headings by a level

Created on 31 July 2023, over 1 year ago
Updated 1 August 2023, over 1 year ago

Problem/Motivation

If I put the following in a markdown field:

# Heading

With the default restrictions, this gets displayed as a normal paragraph.

I could add "h1" to the allowed tags, but there should only be one h1 tag on the page, and that's already in the node title.

Alternatively, I could instruct users to start headings with ##, but that's asking users who are familiar with Markdown to do something they don't expect.

Steps to reproduce

Proposed resolution

The ideal solution would be to have an option to demote headings a level, so # would be converted to h2, and so on down.

For bonus points, it would be fantastic if the headings could be relative to the node title tag, so when the node is a page, and it's title is the h1 tag, # would become h2, ## would be h3, etc. However, if the node is being displayed in a list, the node title would become h2, so # should become h3. However, I'm not sure if a content filter can detect that.

Remaining tasks

I'm guessing this require an extension to Common Markdown.

User interface changes

API changes

Data model changes

Feature request
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

🇮🇪Ireland lostcarpark

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lostcarpark
  • 🇮🇪Ireland lostcarpark

    Of course this problem also occurs with HTML output, except that editors such as CKEditor solve it by only offering H2 down.

    An alternative solution would be to create another filter that fixes the problem after conversion to HTML.

    I did a quick search, and the first answer I've found is the Heading Normalizer module, but that hasn't been ported from D7.

  • Status changed to Closed: won't fix over 1 year ago
  • 🇺🇸United States ultimike Florida, USA

    In an effort to keep this module as simple as possible, I don't think this is a feature that I'm willing to add.

    One (simple) solution would be to add
    to the list of tags not allowed by the "Limit HTML" filter. @lostcarpark's idea is also a good one, IMHO:

    An alternative solution would be to create another filter that fixes the problem after conversion to HTML.

    I really don't like the idea of automatically heading level based on existing tags or any other methodology. If the user enters ### My heading then they expect (and should always get) an <h3>.

    -mike

Production build 0.71.5 2024