-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
id property is always removed when using <h2> tag #27
Comments
ah, it’s because https://github.com/syntax-tree/hast-util-sanitize/blame/fafff8ac1073414ef7babb6063ed9bec9b2f2cb6/lib/schema.js#L39 is now used by GH. Interesting. |
Oh, interesting. So, |
You can change the h2 stuff in your schema? The default schema is that way because that's the default on github. |
Oh I see what you're saying. Something like this
|
@tommyvn responding here from the other issue, where you said:
The scheme, the default handling, is the feature indeed! So: there’s a nice workaround as @ben519 shows above, though it probably should be fixed, so if someone wants to do the work and spend some time on it, that’d be appreciated! |
I agree. It's extra confusing that I'm not sure what the optimal solution is, but I think it'd be great to call out https://github.com/syntax-tree/hast-util-sanitize/blob/main/lib/schema.js in the docs (README). Would've saved me a lot of headaches debugging. |
I’d appreciate a PR linking it directly in the docs! |
Will do, but give me a few days to get to it. |
Initial checklist
Affected packages and versions
5.0.0
Link to runnable example
No response
Steps to reproduce
This is a weird one as
<h1>
,<h3>
,<h4>
, ... tags all work. It's just<h2>
that has a problem.In the below code, I'm attempting to sanitize the html string
<h2 id="foo">Hello, world!</h2>
. I want the id to be retained (or at least sanitized into user-content-foo). However, it is removed entirely.Expected behavior
<h2 id="user-content-foo">Hello, world!</h2>
(The id property should not be removed.)
Actual behavior
<h2>Hello, world!</h2>
(The id property is removed.)
Affected runtime and version
node v20.5.1
Affected package manager and version
npm 10.0.0
Affected OS and version
mac os 13.5.2 (22G91)
Build and bundle tools
No response
The text was updated successfully, but these errors were encountered: