Formatting HTML content for colour-terminals (was: Rendering HTML as Markdown in mutt)
martin f krafft
madduck at madduck.net
Fri Nov 1 01:24:22 UTC 2019
Regarding the following, written by "Akkana Peck" on 2019-10-31 at 18:55 Uhr -0600:
>That sounds like it's all on the viewing side? I can't speak for
>Derek, but in addition to viewing HTML messages, I (and others who
>have added to this thread) would like a way to reply without losing
>the formatting.
You mean "losing the formatting" of the message sent to you?
This is going to get really hard very quickly. Either you convert
the HTML into Markdown, blockquote it, and then hope that the
Markdown to HTML conversion does it justice (probably your best bet
to be honest), or you wrap the original HTML into a blockquote and
include it verbatim. That is certainly the domain of an HTML editor,
I'd say, and it'll get ugly really fast.
>The viewing side isn't so hot either. Most terminal programs these
>days can display colors, italics, bold, underline and strikethrough
>(looks like urxvt doesn't do strikethrough and xterm doesn't do
>underline, but those might not be too hard to patch in). So why do
>most HTML->text conversion programs ignore styles and colors in
>--dump mode? Is there one that shows styles/colors?
This really is only a matter of outputting the right control
characters. I don't know of any that can do it, but I cannot imagine
it being hard work on top of Python `html2text`, i.e. I'd let that
do the conversion to Markdown, and then see if I can replace the
Markdown formatting with terminal control characters.
Helpful link:
https://rosettacode.org/wiki/Terminal_control/Coloured_text
>Sure, it's easy enough to bind a key to bring up a browser window
>showing the message. But then I have an extra GUI window that isn't
>part of mutt, and it breaks that nice fast keyboard-driven workflow
>that's a big part of why I use mutt in the first place. It would be
>so nice to have it all right there in the pager.
Step 1 to check: can mutt's pager handle terminal control characters
for formatting, or is ncurses going to get in the way?
I just tried to make my HTML dumper output red text like so:
tput setaf 1 #red
echo "Red"
tput sgr0
but that didn't get the desired result. So I am thinking that
ncurses actually gets in the way, and I am way outside my depth with
that, but irssi can do it, and so it should also be possible with
mutt.
--
@martinkrafft | https://riot.im/app/#/room/#madduck:madduck.net
"time flies like an arrow. fruit flies like a banana."
-- groucho marx
spamtraps: madduck.bogus at madduck.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mutt.org/pipermail/mutt-users/attachments/20191101/6f1b364c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: digital_signature_gpg.asc
Type: application/pgp-signature
Size: 1118 bytes
Desc: Digital GPG signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)
URL: <http://lists.mutt.org/pipermail/mutt-users/attachments/20191101/6f1b364c/attachment.asc>
More information about the Mutt-users
mailing list