Repository navigation
Read HTML script and style bodies as text up to their closing tag [minor] - #741
Merged
Merged
Conversation
…nor] The markup tokenizer started a tag at any `<` followed by a letter, inside a script or style body as well, and an attribute value then ran to the next matching quote. An ordinary inline script with `count<limit` and an apostrophe in a later comment coloured every following line of the HTML as one string, though the class doc and README said these bodies are text. LanguageDefinition.RawTextElements names the elements whose body is raw text; HTML sets it to script and style. After such an opening tag the tokenizer emits everything up to `</name` (any case, not followed by a name character) as Plain. XML is unchanged. Fixes #738 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW1ukQkdr8Cyf3p9j6Z
|
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The markup tokenizer started a tag at any
<followed by a letter, including inside a<script>or<style>body, and an attribute value then ran to the next matching quote. An inline script needs only two things to trigger this:count<limit, then an apostrophe in a later comment. Together they coloured every following line of the HTML block as one string. The class doc and the README both said these bodies are treated as text.Change
LanguageDefinition.RawTextElements: the markup elements whose body is raw text. HTML sets it toscriptandstyle. XML leaves it empty, so<script>in XML is still markup.MarkupTokenizeremits everything up to</nameas a singlePlaintoken. The name matches in any case, and the match must not be followed by a name character, so</styles>does not close<style>. A self-closing<script/>opens no body.MarkupTokenizer.Tokenizenow takes the definition. Both call sites (HighlightCache,EmbeddedExpander) pass the one they already hold.SyntaxHighlighting/README.mdand the class doc now describe what actually happens.I left out the issue's optional extra, which would end an unterminated attribute quote at
>or at a newline. HTML allows both inside a quoted value, so that change would break valid markup.Tests
MarkupTokenizerTestsgains four tests:Plain, and the following<p class="intro">and<a href="/docs">come out as tags, attribute names and values.<STYLE>body containing'</b>'and</styles>is closed only by</Style>.<script><item/></script>as markup.Results:
SyntaxHighlighting.Testspasses (111/111).SyntaxHighlightingis clean.Fixes #738
Generated by Claude Code