leafac / kill-the-newsletter

Convert email newsletters into Atom feeds
https://kill-the-newsletter.com
MIT License
2.31k stars 113 forks source link

Option to strip styles #74

Closed qrohlf closed 3 weeks ago

qrohlf commented 1 year ago

First off, thanks for this, I am a long-time RSS user (rip google reader) and dislike the modern writing-on-the-internet ecosystem's insistence on email newsletters so it solved a huge annoyance for me.

I subscribe to several email newsletters that include <style> tags as well as inline styling in the email in a way that looks quite bad on my client of choice (Reeder 5).

One possible solution would be to ignore the HTML version of the email and expose an option to only read the plaintext version, since most (but not all) email newsletters send dual text/html and text/plain versions of the newsletter content. However, this would also end up stripping hyperlinks which is probably a pretty undesirable outcome for most use cases.

I think a better solution would probably be to expose an option to strip styles from the HTML email contents before outputting it to the atom feed. We'd have to do some basic HTML parsing/manipulation but that's very achievable in a robust, secure, and performant way.

I'd be happy to write a pull request that adds an "advanced options" menu1 to the signup flow below the Subscribe to the Atom feed at $email zone with two options:

If checked, nothing would actually change in terms of what's being persisted to the backend, but it'd add some query params to the generated feed URL:

https://kill-the-newsletter.com/feeds/n63l428kptihi4lv.xml?strip-style-tags=true&strip-inline-styles=true

Which I'd then read in the request handler, pass the options through to the renderFeed function, and update that function to do the style-strip operation if those options are true.

How would you feel about a PR that does what I just outlined above?


1 Fun tidbit, I'd probably recommend we implement this as a collapsed-by-default menu, which we can do without any extra JS using a details disclosure element:


<details>
    <summary>Advanced Settings</summary>
    <div><label><input type='checkbox' name='strip-style-tags' /> Strip style tags</label></div>
    <div><label><input type='checkbox' name='strip-inline-styles' /> Strip inline styles</label></div>
</details>
leafac commented 3 weeks ago

Hi @qrohlf,

Thanks for reaching out.

I thought about this and decided that we won’t introduce this feature for now. I prefer to stay away from the business of parsing and modifying the contents sent by the newsletter publishers. I think that the feature you described makes more sense in the feed reader.