Skip to content

Add support for headings in details summaries#2917

Open
waylan wants to merge 1 commit into
facelessuser:mainfrom
waylan:summary-heading
Open

Add support for headings in details summaries#2917
waylan wants to merge 1 commit into
facelessuser:mainfrom
waylan:summary-heading

Conversation

@waylan

@waylan waylan commented Jun 15, 2026

Copy link
Copy Markdown

I implemented the heading-only behavior as you requested. It wasn't difficult. I just copied and modified the regex for hash-heading to not check for lines before/after as there is never going to be multiple lines within a detail title.

@gir-bot gir-bot added S: needs-review Needs to be reviewed and/or approved. C: details Related to the details extension. C: source Related to source code. C: tests Related to testing. labels Jun 15, 2026
@facelessuser

Copy link
Copy Markdown
Owner

This is a good working prototype. I think the only other thing I'd probably do differently is either enforce a space after # for the line to be considered a header (so as not to conflict with plugins that process GitHub issues #2, etc.). Either that, or I'd at least have a toggle to enforce/disable such behavior. Personally, I prefer enforcing the space over the more relaxed approach; if there are those who care strongly enough, a toggle may be preferable.

@waylan

waylan commented Jun 15, 2026

Copy link
Copy Markdown
Author

I thought about requiring a space but didn't add that because it is not required for heading elsewhere in the syntax. That seemed inconsistent to me. But then I also was thinking there was no other syntax which could conflict. I hadn't thought of github issues. Personally, I am indifferent to the idea and don't see much need for a toggle.

@facelessuser

Copy link
Copy Markdown
Owner

Like I said, for me, the space is preferred, but I could go with a toggle if people wanted access to something consistent.

My preference is strong enough that I override the default headers with my own plugin https://facelessuser.github.io/pymdown-extensions/extensions/saneheaders/.

I guess I could look for the existence of our own (pydmownx.saneheaders) plugin in the registered plugin list and change the behavior if it is installed. That locks us to default and specifically our header override, which I'm also fine with.

I'm not specifically asking you to do any of this, only noting that I'll likely want to make the space behavior accessible, one way or another, before I pull this in.

@waylan

waylan commented Jun 15, 2026

Copy link
Copy Markdown
Author

So obviously Markdown's default has to stay as-is due to many existing documents (despite any preference on our parts). However, for a third-party extension, anything is game. As there should not be any pre-existing documents in which headings without spaces exist in the titles of details blocks, there is no backward compatibility issue. You can do whatever you want. It works as-is for my needs. I always include a space myself, so would be indifferent if you added the requirement without a way to toggle it.

@facelessuser

Copy link
Copy Markdown
Owner

Yep, sounds good. I'll figure out what direction I want to head in and revisit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C: details Related to the details extension. C: source Related to source code. C: tests Related to testing. S: needs-review Needs to be reviewed and/or approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants