Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add table support to Moggie's HTML-to-text conversion #5

Open
BjarniRunar opened this issue Feb 8, 2023 · 0 comments
Open

Add table support to Moggie's HTML-to-text conversion #5

BjarniRunar opened this issue Feb 8, 2023 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@BjarniRunar
Copy link
Member

BjarniRunar commented Feb 8, 2023

Moggie's HTML-to-text conversion in moggie.security.html.HTMLToTextCleaner is used for generating most plain-text e-mail views, and is preferred by default over the text parts including in the e-mails themselves simply because so many systems generate broken or incomplete text parts these days.

The class does a decent job generating readable text from HTML input, including links, images and tags such as pre, blockquote and ul - but the structure implied by a table is currently ignored.

This means we are losing some important information from e-mails sent by financial institutions, travel itineraries, and probably some others. (This isn't just layout for marketing messages!)

So we should support tables!

Currently the code inherits from HTMLCleaner a depth-first algorithm which converts each tag into text in the rerender_tag method. This needs to change - the depth-first code will need to buffer the table contents (including tables within tables) and postpone processing them until the size/structure of the table is known, allowing us to allocate a width to each table column, and then render cells side-by-side in the plain text.

@BjarniRunar BjarniRunar added enhancement New feature or request help wanted Extra attention is needed labels Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant