-
Notifications
You must be signed in to change notification settings - Fork 129
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
Incude line and column info from the original file #89
Comments
@lazarljubenovic Thanks for making this issue. Having column/line numbers would definitely play to Himalaya's strength in being an accurate-representation parser. I don't think implementing this would be too hard, it's two more things to book-keep during parsing. My question is for the interface Element {
...,
startTagPosition: {
start: { line: number, col: number },
end: { line: number, col: number },
},
endTagPosition: {
start: { line: number, col: number },
end: { line: number, col: number },
}
} Along with the
I cannot say I'll get to this immediately, but it is worth adding. |
Hmm. Interesting question. If we add that, then one might expect to do a similar thing for attributes' key-value pairs. In which case it's not obvious how to handle the tag itself: do we need a location for the tag name only? Are Curently Himalaya doesn't preserve any info about the way HTML was written (did you include a closing tag? did you wrap attribute value in quotes?), so it's a bit tricky to see how to do this as this is info about the original file, not the compiled JSON (and a first of such kind we're introducing here). There's no other convention established yet to compare it to. Having the above in mind, this is what I suggest. (Lowercase letters are the "start" markers and their corresponding uppercase letter is the "end" marker. They are on separate lines to allow multiple markers on the same character.)
In my opinion, making it more sophisticated than this would be peeking into the lexer. Maybe it will be useful in the future to add all lexical nodes which participated in creating a parsed node, and see additional info there. It's just my two cents, of course. |
Hey, thanks a lot for adding this! 🎉 Sorry for the super-late reply 😓 |
Thanks for this great library!
It would be nice if parsed nodes contained information about the start and end of themselves.
Every node could have an additional property
pos
, something along the lines of the following.The text was updated successfully, but these errors were encountered: