Configure CSS and color support
mainWhen the css feature is enabled, html2text can handle basic CSS selectors and colors.
Style Sources
Style rules are sourced from:
- Document
<style>elements - Inline
styleattributes <font color=...>tags- Custom rules added via
Config::add_css(...)(available regardless ofuse_doc_css()setting).
Accessing Colors
To utilize CSS colors in your output, you have two options:
- Rich Annotations: Use
from_read_rich()or its variants. This returns a tree containingColour(..)annotations. - Direct Coloring: Use
from_read_coloured(). This function accepts a closure that allows you to mapRichAnnotationsdirectly to terminal styling (e.g., usingtermion).
// Example concept: using from_read_rich to get annotations
// let rich_text = from_read_rich(&html[..], 80);
// // rich_text will contain nodes like Colour(..)