-
Notifications
You must be signed in to change notification settings - Fork 236
Provide source spans for tokens and DOM nodes #48
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
Comments
I am interested in this feature. What is the status of this? Is there some spanning information available or is this yet to be implemented? My use case is that I am using html5ever in my proc macros to parse templates for a web framework and I would like to give errors with spans that point various parts of the original HTML |
The tree builder sink is notified when the current line is updated via html5ever/html5ever/src/tree_builder/mod.rs Line 459 in 36ee935
|
Are there any plans to add this to rcdom/markup5ever? |
I would also love to have support for (The use case is editing certain parts of HTML documents, but most of the document should just stay exactly as it is. [Not parse and serialize again, just leave it untouched.] Then I could parse it with html5ever and just edit the relevant parts of file.) |
We can use something like libsyntax's
Span
andSpanned
types to track positions in the input stream.The tokenizer will remember its current position and the position at certain events, e.g. start tag, start attribute name. The tree builder will call a tree sink method (with an empty default) to annotate the DOM with span information.
Then we can write a command-line HTML validator with the same output UI as rustc :)
Note that eventually it will be possible for a single document's nodes to come from multiple text sources, e.g. with
document.write
.The text was updated successfully, but these errors were encountered: