5 ms·
Years ago I made a Go library called `html2text' just for this: https://github.com/jaytaylor/html2text/ https://github.com/jaytaylor/html2text/ https://jaytay
by jaytaylor 4y ago
Years ago I made a Go library called `html2text' just for this:
https://github.com/jaytaylor/html2text/ https://github.com/jaytaylor/html2text/
https://jaytaylor.com/html2text https://jaytaylor.com/html2text
It takes HTML as input and generates markdown-esque plaintext, with the main focus being to make the plaintext version easy and pleasant to read for human beings. Then using MIME types*, you transmit both the rich html version alongside the generated text/plain version.
This is cool because it makes it easy to respect both rich clients (like Gmail et. al.) as well as command-line or other clients which work better with simple text.
Hope this helps folks have the best of both worlds! :) cheers
* n.b. To ensure this works properly, be sure to use the right MIME headers:
https://stackoverflow.com/questions/3902455/mail-multipart-alternative-vs-multipart-mixed https://stackoverflow.com/questions/3902455/mail-multipart-a...
- joshmanders 4y agoYep, I do similar with all emails I send, run the html through a `html2text` transformer and attach that as the plaintext variant of the email. Now whatever the receiver decides they want to view they can.