rust-html2text
rust-html2text copied to clipboard
Text decorator functions for all elements?
Is it possible to implement text decorator functions for all elements? The current implementations for plain and rich text are already very helpful, but I would like to tweak the appearance of some specific elements. Let’s say I want to print headings with a bold typeface or I want to set the color based on the element’s class. This could be done with functions like:
fn decorate_element_start(&self, name: &str, attrs: HashMap<String, String>) -> Self::Annotation
fn decorate_element_end(&self, name: &str) -> Self::Annotation
That sounds potentially useful, and could become part of the solution for #20.
I'm slightly concerned at the overhead (creating hash maps and calling the decorator for every element), but I guess the compiler could remove most of that for decorators which don't make use of it.