-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Highlighting multiple code
s in the same pre
is broken
#34
Comments
Does it? The code seems to check Aside: Looks like you might want a “copy” button? |
Bug seems to be |
I would say this, exactly. 👍 try {
result = lang
? lowlight.highlight(lang, toText(parent), {prefix})
: lowlight.highlightAuto(toText(parent), {prefix, subset})
} catch (error) {
// ...
}
Nope. This is not about that. The issue effects |
This comment has been minimized.
This comment has been minimized.
My guess is that, because |
code
s in the same pre
is broken
Released in |
You are so speedy, thank you too :) |
Initial checklist
Affected package
rehype-highlight
Steps to reproduce
rehype-highlight
highlights thepre
content instead ofcode
content.Actually,
<pre>
tag defines preformatted text and preserves both spaces and line breaks.A
<pre>
element can hold text, anchor tag, or contain multiple<code>
elements. It is valid HTML usage.It is not suitable or is a violation to have additional elements in
pre
other thancode
; but,rehype-highligt
should actually preserve the xml structure ofpre
element and not interfere with other elements' contents insidepre
other thancode
, and focuscode
element content for code highlighting. For some reasonpre
element may have additional elements like copy content button or footer etc, or may have more than onecode
element.See the
rehype-highlight
behaviour:I realized this situation while testing
rehype-highlight-code-lines
as a result of having undesired additional line containers which contains undesired content/spaces.Actual behavior
rehype-highlight
highlights thepre
content instead ofcode
content.Expected behavior
rehype-highlight
focuses and highlights thecode
content instead ofpre
content.Runtime
node@20
Package manager
npm@11
Operating system
macos@latest
Build and bundle tools
No response
The text was updated successfully, but these errors were encountered: