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
Provide Tag and Event source locations. #725
Comments
It seems a pretty big change, but it may be very useful and it will be considered. Thanks for your suggestion |
For reference, I have implemented it in my fork here. I estimate ~1/3 of the additions is due to
As I had a lot of code already working with events the way they are currently structured, I ended up:
Using As all places that were constructing Adding If you want I can make a PR, but I'm not entirely happy with |
FWIW, I don't see how this external API change would help fixing #716. The span of the inline code item is known when the content is collected, but the challenge is trimming indentation from subsequent lines. The idea for a more composable extension system is certainly interesting. It becomes challenging when you want to parse something with higher priority than something else, after the fact. If, for example, strikethrough was implemented as an extension that runs after the fact (or before other inline passes), |
I misunderstood the issue. You're right. I wasn't familiar with the codebase yet and assumed too much.
That is also true. From my experiments I've found that parts that are missing for proper composition support are:
I'll do some more testing once I catch up with other stuff and create another issue/PR for composition if someone doesn't do it first. That being said... there's really not much use for Spans other than that - if the Parser position can't be moved back or forth. |
Interesting idea but out of the scope for the 0.10 version. Maybe it is more for mid term than long term, however. Thanks! |
I want to suggest that
Event
s andTag
s retain their source location and for it to be accessible when they are consumed.Currently, if the CommonMark parses something as an element, there's no way of restoring it back to source form (without possibly losing spacing/symbols).
This would allow multi-line
Event
s to capture raw contents which would make it straightforward to fix issues like #716.It also addresses extensibility as non-standard parsers could detect markers/delimiters in
Event::Text
and reinterpret all intermediate events/tags as raw text for processing. That means that extensions could be implemented as structs implementingIterator<Item = MyEvent>
and wrappingpulldown-cmark::Parser
which would make them very composable.Also, bare CommonMark parser could be separated and extended as needed by end-users, while an extension layer that takes in current
Options
could provide currently supported non-standard functionality.The text was updated successfully, but these errors were encountered: