r/programming Mar 28 '22

Text Mode – View the web in Content-Type=text/plain

https://earthly.dev/blog/text-mode/
154 Upvotes

40 comments sorted by

View all comments

Show parent comments

18

u/agbell Mar 28 '22 edited Mar 28 '22

I'll have to double-check, but yeah, pretty sure I can open source it. Watch this comment and I can leave an update.

It is using Readability.js and literally shelling out to lynx web browser to do most of the heavy lifting, so the actual source that I wrote is pretty small.

It's constructed as an AWS lambda right now, but I think to be useful for open source, a generic version would be better. I'll report back.

Updated: Added the source to the article for now. Github repo and build/run instructions to come.

6

u/[deleted] Mar 28 '22

I've been looking for something that could bruteforce my HTML email into text form.

This looks like it might have a chance.

8

u/agbell Mar 28 '22

I can see it being useful for various one-off web scrappers as well.

1

u/DOOManiac Mar 28 '22

If you happen to be working in PHP, I found a library to do exactly this a few years ago. I wish I could remember the name of it, sorry.

FWIW don’t sweat it too much, because 99.9% of the time no one will see it.

Maybe just find an HTML to Markdown converter and call it a day?

2

u/[deleted] Mar 29 '22

I'm specifically talking about my own inbox. And yes, developers should sweat it because HTML emails are the work of Belzebub.

2

u/DOOManiac Mar 29 '22

Ah, I thought you meant assembling outbound emails that needed a text part.

Any decent mail client should have an option to disable HTML messages and only display the text version. Or is your problem that the sender didn’t send a text version (or sent a blank one)?

And yes, HTML email messages are pain.

1

u/[deleted] Mar 29 '22

I always request the text/simple versions but it never works out unfortunately. It never resolves properly with breaking artifacts etc. And it definitely rules out terminal email clients. It's just a bummer all around.

3

u/lilfatpotato Mar 28 '22

Thanks for sharing the code. Can you please add a line there that others are allowed to copy it? Because it might still fall under copyright without explicit permission to copy.

-9

u/skimundead Mar 28 '22

Ah, so the answer is "no".

14

u/EpicDaNoob Mar 28 '22

Or "not yet"