[Feature Request] Opting-out of phrasing content inclusion
altano opened this issue · 5 comments
In #58 support was added to include phrasing content. Unfortunately, we sometimes might not always want this behavior.
My use case
I'm using gatsby-remark-table-of-contents on a personal blog which uses mdast-util-toc under the covers. I would sometimes like to include images (custom React components in my MDX) in the headings, but I would NOT want to extract these into the table of contents. Currently my MDX looks like:
### Never Pause Here <Chrome />
When you right-click the gutter and select "Never Pause Here," Chrome creates a conditional breakpoint that is `false` and never passes. This makes it so that the debugger will never pause on this line.This creates a TOC entry that is just literally the string "Never Pause Here <Chrome />" when I would like it to be "Never Pause Here".
It would be lovely if including phrasing content was an option that I could opt-out of.
- How would that space also be removed (
'Here'instead of'Here ')? - What if you’d like some to be ignored, some to be included?
- Could this be solved by using a wrapping component?
<MyHeading> ### Never Pause Here <Chrome /> </MyHeading>
Excellent questions! How would I get the wrapping component to render one way (without phrasing content) during the mdast-util-toc scan and another (with phrasing content) during the actual page rendering?
Well, CSS could do the wrapping component maybe? Display the icon next to the heading?
The question to me is: is the icon part of the heading, or does it belong close to it? Should screenreader users and robots also read the icon as part of the heading?
Going to close this as it’s stranded while not yet clear whether the current behavior is a bug. If someone finds this and has more ideas on this, feel free to open a new issue referencing this one!