-
Notifications
You must be signed in to change notification settings - Fork 29
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
Decoupling the html2text rendering pipeline #37
Comments
I think that's a reasonable summary of how it works. Some more notes:
Can you describe the kind of things you want to do differently? |
Thanks for the explanations! I’ll have a closer look at the text rendering code.
It’s not about doing things differently, rather about extending the renderer for special use cases like syntax highlighting or special styling for other elements. |
I had a thought. Perhaps a useful extension point would be the point where a sub-builder is merged into the parent. |
I had a thought. Perhaps a useful extension point would be the point
where a sub-builder is merged into the parent.
I like the idea! Maybe this could also be realized by adding optional
prepare and finalize methods to the decorator that are called before and
after the decorator is used.
|
Another aspect to this topic is that it would be useful to use html2text’s layout mechanisms with a different data source, for example a Markdown document parsed with |
That's an interesting thought. Though as Markdown can contain HTML tags, maybe just going via HTML makes sense. I don't know how common that is, though. |
Right now the
How would you feel about a PR that made this function take in a whole Thanks for the great lib, almost exactly what I needed. |
Hi @grantslatton - sorry I accidentally lost the notification and didn't notice it was about a comment here! |
I’ve spent some time using
html2text
, reading its source code and even writing small patches. Still, I haven’t really grasped the complete rendering process thathtml2text
performs. At the same time, I have some specific requirements like #27 or #36 that cannot be realized withhtml2text
and maybe don’t even belong in a generic HTML rendering library.Therefore, I am wondering: Would it be possible and would it make sense to decouple the html2text rendering pipeline into steps that can be customized by the user? This would make it easier to understand the rendering process, and it might make it possible to implement some of the requirements I mentioned earlier without having to re-implement the entire rendering stack.
From my point of view, these are the steps of the rendering pipeline (while I’m quite confident that steps 1–3 are correct, I’m not really sure about 4 and 5.):
src/lib.rs
).src/lib.rs
).src/lib.rs
).src/text_renderer.rs
?).src/text_renderer.rs
?).TextDecorator
(src/text_renderer.rs
).It would be especially nice if the user would be able to customize step 5 without having to re-implement everything else.
Is my understanding of the rendering process roughly correct? What do you think?
The text was updated successfully, but these errors were encountered: