Skip to content

Conversation

@dpc
Copy link
Contributor

@dpc dpc commented Dec 8, 2025

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.

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)?;
Copy link
Contributor Author

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.

@dpc dpc force-pushed the dpc/jj-yuvtslzkslty branch 3 times, most recently from 5f14185 to de86db0 Compare December 8, 2025 03:07
@dpc
Copy link
Contributor Author

dpc commented Dec 8, 2025

Not a very helpful failed fuzzing output. :/

dpc added 3 commits December 7, 2025 19:50
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.
@dpc dpc force-pushed the dpc/jj-yuvtslzkslty branch from de86db0 to 31c34ff Compare December 8, 2025 04:44
@hellux
Copy link
Owner

hellux commented Dec 14, 2025

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.

@dpc
Copy link
Contributor Author

dpc commented Dec 15, 2025

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.

With a simplified End one just not need to do anything, other than replacing Start(Img) with a Start(Paragraph) or something like it, no? An End is an End, no?

Even html renderer itself usually just discards everything in the end event away.

A simpler end event also has benefits but it is not obvious whether one or the other is strictly better.

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 End event (I simply forgot about it). And if it is to be correct, it will have to do .to_owned twice, just so the second value can get thrown away.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants