-
Notifications
You must be signed in to change notification settings - Fork 18
refactor: simplify Event::End #104
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
base: master
Are you sure you want to change the base?
Conversation
src/html.rs
Outdated
| // not a footnote, so no need to add href before para close | ||
| out.write_str("</p>")?; | ||
| } | ||
| self.render_event(e.clone(), &mut out, indent)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW. This clone can be removed on master by doing let is_end_parapgraph like below, irrespective of this PR.
5f14185 to
de86db0
Compare
|
Not a very helpful failed fuzzing output. :/ |
Redundant data makes it harder for filtering/modifying renderers to do their job, while it is quite simple for html (or any other) actually rendering renderer to keep track of current container nesting.
de86db0 to
31c34ff
Compare
|
I think the container in the end event is still useful for some filters, e.g. things like removing all Image events to convert images to the alt text, or process all Div containers of a certain class becomes quite trivial. I think current End event is beneficial when debugging filters and renderers, it seems easier to understand where each end event came from and belongs if it is tagged instead of always being just End. A simpler end event also has benefits but it is not obvious whether one or the other is strictly better. |
With a simplified Even html renderer itself usually just discards everything in the end event away.
Having redundant information that 99% of the time is throw away is most probably slower, and can lead to subtle mistakes. Eg. https://github.com/hellux/jotdown/pull/101/changes#diff-903e86cc8b353a4224c67d8316226ba19feed61d629a91825ee2a742f4244a6eR18 produces correct output, but is technically incorrect because it does not replace the things in It's not difficult to store the attrs etc. on stack or something when a particular renderer (/filter) needs it, which might be needed anyway for non-trivial manipulations. |
This is on top of existing PRs.
Redundant data makes it harder for filtering/modifying renderers
to do their job, while it is quite simple for html (or any other)
actually rendering renderer to keep track of current container
nesting.