-
Notifications
You must be signed in to change notification settings - Fork 13
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
Feature request: source locations for elements and attributes #5
Comments
It seems that maybe this issue is relevant: cloudflare/lol-html#157 |
Hey! 👋 Apologies for the delayed response here. Thanks for raising this (and for making It looks like It may be possible to pipe this through, but I think it would be tricky with rewriting. Would the original position be returned, or the position in the rewritten document? As this is a streaming parser, we probably wouldn't know all original positions ahead of time, but positions in the rewritten document might not be that useful for user facing errors. In your case, would you be able to return an error based on the content of the elements instead? Could each element have some identifiable marker you could find the location of? |
No worries, I've been quite busy too. My goal is to display errors in the original source file, so I would need the original position, not the position in the rewritten document. The former should be simpler than the latter, since positions don't need to be calculated dynamically. We just need to pass the positions from the lexer's tokens to the parser's AST nodes, and if an error occurs in an |
Any updates on this? |
Hi, first of all, thank you for this fantastic library.
I am using it to transform HTML attributes. During this transformation, it's possible for errors to occur. I'd like to display the source location of the attribute that caused the error. However I don't see any way to get the source location of an element or attribute.
I am using the element handlers like this:
Could this feature be added?
Edit: A simple offset would also work, since I could use it to calculate the line and column numbers myself.
The text was updated successfully, but these errors were encountered: