Open tkapias opened 7 months ago
For the moment I've been able to get the equivalent result by concatenating outputs of both "Rich" and "Plain" with sed
.
It's a bit sloppy, but it's the best result my neomutt has ever seen.
If html2text could do it directly that would be great.
Neomutt's mailcap
:
text/html; auto-view_html %s %{charset} ${COLUMNS:-80}; nametemplate=%s.html; copiousoutput; x-neomutt-nowrap;
auto-view_html
script:
#!/usr/bin/env bash
shopt -s extglob
export LC_ALL="C.UTF-8"
export TZ=:/etc/localtime
[[ $3 -lt 80 ]] && _columns=$3 || _columns=80
html2text --width $_columns --wrap-width $_columns --colour "$1"
echo
html2text "$1" | sed -E '/^\[1\]: /,$!d' | tr -d '\n' | sed -E 's/(.)(\[[0-9]*\]: )/\1\n\2/g'
- Links listed as references, like in the PlainDecorator.
That seems like a reasonable think to want!
My first thought would be to add an option to RichDecorator
(a new constructor that sets a flag) to do the references.
- References wrap at --wrap-width,
I think it should be at the --width
. But some reports have said that URLs work better if they're not manually wrapped - so maybe that should be an option (internally anyway).
to help with long links osc 8.
There is #119 , opened recently. It seems reasonable as an option to the html2text
binary, and I think can be done in the default_colour_map()
function.
- Assign a color to borders and horizontal lines, to dim them.
That sounds like the hardest thing!
There may be a quick-and-dirty way to colour all borders the same (which sounds like what you want), but if that's possible it seems a shame not to support the border-color
CSS styles, and that needs some thought.
In case it helps, there was a change just merged (#129 ) which adds an option to not draw the borders, in case that solves your problem in the short term.
Thank you,
I will try to write something for RichDecorator
another day.
About the references width, the issue is that some pagers (like the internal one in neomutt) do not support osc 8, and they wrap urls making it impossible for most terminals to parse them (urxvt has a marker extension to select urls but parse per line). So to copy an url, without an external tool, you need to select multiple lines manually: the wrapped URLs must reach the screen's border to avoid spaces.
I will go write a comment about osc 8 in #119.
About the new options in #129, thanks, it works. I put config = config.raw_mode(true);
in the example.
It is better in most cases but I think that I will miss the borders sometimes, or at least some horizontal separators.
Intro
I tried many solutions to display html emails in mutt/neomutt's internal pager (elinks, readability tools, pandoc, html2text tools), but there was always some issues with the encoding, colors, references or parsing.
After a few tests today, rust-html2text seems to be the way to go, it's fast and the parsing, format, and encoding are spot on.
Request
I changed colors and styles options in the
html2text
example to fit my tastes, but I would like to add 3 features to theRichDecorator
, used by --colour in the example:PlainDecorator
.--wrap-width
, to help with long links osc 8.Would you have time to implement those or give me some leads? (I'm just starting rust)
Extra
My changes to the example (only
Reset
for colors and style was not working correctly for me):