Skip to content
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

Add optional way to track positions in parser #148

Open
8 tasks
bwrrp opened this issue Nov 6, 2023 · 0 comments
Open
8 tasks

Add optional way to track positions in parser #148

bwrrp opened this issue Nov 6, 2023 · 0 comments

Comments

@bwrrp
Copy link
Owner

bwrrp commented Nov 6, 2023

For some applications it would be helpful to have a way to map a given node back to its corresponding span(s) in the source XML. We could add an optional map argument to the parse options that can be populated with a mapping of nodes to such position information.

TODO:

  • extend internal parse events with position information where necessary
  • decide which spans to expose for which nodes:
    • text nodes may be actual character data + references, should these be a single span or multiple?
    • elements have a start and end - single span including contents or separate spans for start and end tags
    • what about attributes?
    • other bits of data? names?
  • add option
  • convenience methods to translate start and end offsets to column + line?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant