views:

179

answers:

2

Do you know any good HTML to plain text conversion class written in PHP?

I need it for converting HTML mail body to plain text mail body.

I wrote simple function, but I need more features like converting tables, adding links at the end, converting nested lists…

-- regards
takeshin

+2  A: 

I'd suggest using a HTML to Markdown converter.

ceejayoz
And what good is markdown in a text email?
Question Mark
Uh, have you used or read anything about Markdown? "The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. **The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions.**"
ceejayoz
Markdownify is a good solution, indeed. I looked at it before, but I thought that it does not converts tables. But the problem was, that I tried on tables with `<caption>` attributies and some css styles.I stripped manually captions and class and style attributies, and it works nice.
takeshin
Awesome, glad it worked!
ceejayoz
+1  A: 

A particular mail sending implementation around here simply spawns lynx with the HTML and uses its output for the text version. It's not perfect but works. You might also use links or elinks.

Joey
Neat idea, I like it.
ceejayoz
Yes, this was already suggested on StackOverflow, but I was asking for PHP soultion. I do not have access to lynx to my server. Thanks.
takeshin