jaytaylor / html2text

Golang HTML to plaintext conversion library

Home Page:https://jaytaylor.com/html2text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Table formatting not useful

MarcGrol opened this issue · comments

I am using html2text in my unit-testing to extract the "essence" from html formatted emails.
As you know, html-formatted emails use a specific html dialect that use (deeply nested) tables intensively.
Since the introduction of the new table-formatting html2text become completely useless for me.
For now I will vendor the former version, but do you have any ideas how to go on?
I can for example add a feature-toggle to disable/enable formatted tables?

Oh no! I'm sorry to hear that we've inadvertently broken you. Appreciate you reaching out in such a timely manner!

I'm confident we can find a way to accommodate all our collective needs in this case.

My first impulse is to add some config options so that we can control the rendering behavior. Perhaps it'd look like an optional extra parameter with a flag to disalbe ASCII table rendering.

Does this sound like a reasonable compromise / approach? Any other ideas on how we can best resolve this issue? I'm all ears! :D

Thanks for your response. Your suggested approach would allow me to keep using the latest and greatest version of html2text.

Hey @MarcGrol,
I'm the one responsible of breaking your usage :(. I agree with @jaytaylor solution.

In my opinion, I think the default behavior should be the old display. And an option like "PrettyTable" could be enabled.

Moreover, this kind of options could be used for example to replace the character used for converting the lists "* vs -"

@MarcGrol do you plan to make the PR or should I do it ?

@matcornic I'm working on a PR for this, may have something later today or if I don't get to it before Friday I'll have some time this weekend.

Once I open the PR I'll select you both as reviewers so we can ensure it's good for everyone :)

Thanks!

cc @MarcGrol

@matcornic @MarcGrol GH currently not letting me request reviews from you, so if you're able please try / check it out and let me know what you think!

Cheers,
Jay

@jaytaylor looks fine to me, i commented the PR :)

Sorry for the delay.
@jaytaylor @matcornic: Reviewed and tested this specific version against my software and everything works fine again.
I am glad I can keep using the latest and greatest version of the html2text package.
Thanks a lot for creating the PR.