Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heading levels #989

Open
eereeska opened this issue Aug 5, 2023 · 3 comments
Open

Heading levels #989

eereeska opened this issue Aug 5, 2023 · 3 comments
Labels
enhancement New functionality or behavior up-for-grabs Please feel free to take this one!

Comments

@eereeska
Copy link

eereeska commented Aug 5, 2023

Description

Please, add ability to control allowed heading levels such as CKEditor do

Example

It can be via config, similar to heading_permalink:

'heading_permalink' => [
    'min_heading_level' => 1,
    'max_heading_level' => 6,
],

To:

'headings' => [
    'min_level' => 2,
    'max_level' => 4,
],

So # H1 will became ## H2 & ###### H6 became #### H4 (closest allowed one)

Did this project help you today? Did it make you happy in any way?

Definitely love it ❤️

@eereeska eereeska added the enhancement New functionality or behavior label Aug 5, 2023
@eereeska
Copy link
Author

bump

@samwilson
Copy link

Would this mean that e.g. with min_level=2 a heading with one asterisk # Head would be rendered as <h2>?

A use case that I often have is that a document with headings needs to be rendered both standalone (where it's headings would be as written) and also as subsections (where the headings would all be dropped down a level). Is that the sort of thing that this would accomplish?

@colinodell
Copy link
Member

This suggestion makes sense to me.

I'd recommend we create a separate extension for it, perhaps called LimitHeadingsExtension or something similar. That extension could observe the DocumentParsedEvent and run some code to adjust the heading levels throughout the parsed AST.

Anyone interested in contributing this? 😉

@colinodell colinodell added the up-for-grabs Please feel free to take this one! label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New functionality or behavior up-for-grabs Please feel free to take this one!
Projects
None yet
Development

No branches or pull requests

3 participants