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

Uncaught DOMException: Element.querySelector: '#3-1-some-title-level-3' is not a valid selector #92

Open
bitonio opened this issue Jan 17, 2024 · 2 comments

Comments

@bitonio
Copy link

bitonio commented Jan 17, 2024

Hello,

First, thanks for this plugin.
I have some user generated Markdown converted to HTML with heading, without specifying the ID.
The anchor generated by this plugin are friendly although if the heading starts with a digit, like

<h3> 3.1 Some title level 3</h3>

It will generate an id/anchor 3-1-some-title-level-3
This is not supported by querySelector.

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id

Similarly, an id starting with a digit (E.g., 1234-322-678) or a hyphen followed by a digit (E.g., -123), though valid in HTML, may lead to problems when used in CSS, JavaScript, and Web APIs

@afeld
Copy link
Owner

afeld commented Jan 17, 2024

Hmm. What do you think it should do instead? Happy to review a pull request. A workaround is that you can generate your own ids, and the plugin will use those.

@bitonio
Copy link
Author

bitonio commented Feb 10, 2024

Hi @afeld,

I'll open a pull request I have changed slightly the code to add a one letter prefix in case the id starts with a number, that does the trick. The upstream markdown code was generate by Python-Markdown and a few addons, the ids were also starting with numbers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants