[gatsby-remark-autolink-headers] Ignore HTML in headers when generating ID #29449
Unanswered
jerelmiller
asked this question in
Ideas / Feature Requests
Replies: 1 comment
-
Hi. This is a good idea. I'm going to convert this to a discussion, as it's a feature request, but it does look like something we should look into. If anybody would like to open a PR, it would be welcome. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
When using the
gatsby-remark-autolink-headers
plugin, markdown images contained in the header are included as part of the ID. On top that, it appears thearia-label
includes a semi-stringified HTML representation of the image.For example, take the following markdown:
## ![[email protected]](./images/img-integration-aws%402x.png "[email protected]") AWS integrations
This results in a header that looks like the following:
I suspect it has to do in part with the use of
mdast-util-to-string
. According to that utility:Would it be possible to filter out images from this check to avoid counting them as part of the ID string? I would expect only the non-image text to be counted as part of the
id
Reproduction steps
You can see this in action on the New Relic Doc's site. We will be launching this site on March 3rd, so depending on which side of the launch date you're are on, you'll want one of the following 2 links:
Before March 3rd
https://docs-preview.newrelic.com/docs/full-stack-observability/instrument-everything/instrument-core-services-applications/cloud-services-integrations
On/after March 3rd
https://docs.newrelic.com/docs/full-stack-observability/instrument-everything/instrument-core-services-applications/cloud-services-integrations
Inspect the headings with images to see the result. You can see the raw code in the repo here
Environment
System:
OS: macOS 11.2
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.20.0 - /var/folders/bv/xv70fx350vd2htmc8vjb8h6w0000gn/T/yarn--1613010452125-0.12682654755096645/node
Yarn: 1.22.5 - /var/folders/bv/xv70fx350vd2htmc8vjb8h6w0000gn/T/yarn--1613010452125-0.12682654755096645/yarn
npm: 6.14.9 - ~/.nvm/versions/node/v12.20.0/bin/npm
Languages:
Python: 3.7.7 - /Users/jmiller/.pyenv/shims/python
Browsers:
Chrome: 88.0.4324.150
Safari: 14.0.3
npmPackages:
gatsby: ^2.32.0 => 2.32.0
gatsby-image: ^2.7.0 => 2.7.0
gatsby-plugin-json-output: ^1.2.0 => 1.2.0
gatsby-plugin-manifest: ^2.8.0 => 2.8.0
gatsby-plugin-mdx: ^1.9.0 => 1.9.0
gatsby-plugin-meta-redirect: ^1.1.1 => 1.1.1
gatsby-plugin-offline: ^3.6.0 => 3.6.0
gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10
gatsby-plugin-sharp: ^2.14.0 => 2.14.0
gatsby-remark-autolink-headers: ^2.7.0 => 2.7.0
gatsby-remark-copy-linked-files: ^2.6.0 => 2.6.0
gatsby-remark-images: ^3.11.0 => 3.11.0
gatsby-source-filesystem: ^2.7.0 => 2.7.0
gatsby-transformer-json: ^2.9.0 => 2.9.0
gatsby-transformer-remark: ^2.12.0 => 2.12.0
gatsby-transformer-sharp: ^2.12.0 => 2.12.0
gatsby-transformer-yaml: ^2.7.0 => 2.7.0
Beta Was this translation helpful? Give feedback.
All reactions