Repository navigation
fix: Let tree-building parses report the locations streaming ones do - #131
Open
sideshowbarker wants to merge 1 commit into
Open
sideshowbarker wants to merge 1 commit into
sideshowbarker wants to merge 1 commit into
Conversation
Problem: In the Nu HTML Checker, with --no-stream, each HTML parser message got a range that started at the start of the document — or at the end of the previous message — so its extract and highlight took in all the markup from there to the error. And a checker message reported at an end tag got no location at all. Cause: When its streamability violation policy is ALLOW, HtmlParser uses its SAXTreeBuilder, which builds the whole tree before TreeParser replays it as SAX events. So a SAX consumer that tracks locations had none for any error the parser reported, which the checker needs to find where the range of each error starts. Also, SAXTreeBuilder never set an element’s end locator, so the replay gave endElement events no location. Fix: As SAXTreeBuilder builds the tree, it now sends the events a streaming parse emits, at the same points, to any handlers set with the new HtmlParser.setTreeBuildingWiretap() — so those handlers get the same locations a streaming parse gives, interleaved with the parser’s errors. SAXTreeBuilder also now sets the end locator of each element it pops. Fixes validator/validator#2168
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.
Problem: In the Nu HTML Checker, with
--no-stream, each HTML parser message got a range that started at the start of the document — or at the end of the previous message — so its extract and highlight took in all the markup from there to the error. And a checker message reported at an end tag got no location at all.Cause: When its streamability violation policy is
ALLOW,HtmlParseruses itsSAXTreeBuilder, which builds the whole tree beforeTreeParserreplays it as SAX events. So a SAX consumer that tracks locations had none for any error the parser reported, which the checker needs to find where the range of each error starts. Also,SAXTreeBuildernever set an element’s end locator, so the replay gaveendElementevents no location.Fix: As
SAXTreeBuilderbuilds the tree, it now sends the events a streaming parse emits, at the same points, to any handlers set with the newHtmlParser.setTreeBuildingWiretap()— so those handlers get the same locations a streaming parse gives, interleaved with the parser’s errors.SAXTreeBuilderalso now sets the end locator of each element it pops.Fixes validator/validator#2168