Thread: Email raw text to HTML

Email raw text to HTML

From
Sahil Harpal
Date:
Hello,
I am curious about how Gmail converts plain text (Raw data) mail into a beautiful interface. Is there any library or something that will help us to transform plain text into HTML? 
I am aiming to represent text (email message body) as it is being displayed in any mailing services like gmail, yahoo or outlook. The motive is the text should be readable. It is not just about enclosing previous replies in the blockquote tag but we can even handle bold, italic, bullets, tables etc.

For example:
image1 => Gmail interface 
image2 => Mailing list view

Is there any method to do this conversion?

I tried replacing '>' to '| ' [image3]. And I think it is better than what is present. It will look better if we change color and background color for quoted text. But for this we actually need something that will help us to convert raw text to good looking HTML same as markdown does. But in case of markdown the syntax is different. For example it uses **text** for bold and gmail uses *text* for bold.

Thanks,
Sahil Harpal

Attachment

Re: Email raw text to HTML

From
Magnus Hagander
Date:
On Thu, Aug 4, 2022 at 11:55 AM Sahil Harpal <sahilharpal1234@gmail.com> wrote:
>
> Hello,
> I am curious about how Gmail converts plain text (Raw data) mail into a beautiful interface. Is there any library or
somethingthat will help us to transform plain text into HTML? 
> I am aiming to represent text (email message body) as it is being displayed in any mailing services like gmail, yahoo
oroutlook. The motive is the text should be readable. It is not just about enclosing previous replies in the blockquote
tagbut we can even handle bold, italic, bullets, tables etc. 

As a regular user of gmail, I think that would be a bad way to go. I
find gmails way of rendering emails is particularly bad when it comes
to things like inline code snippets etc. For one, it insists on not
using a monospace font...

It might be workable if it can be made a configurable thing with a
checkbox or so somewhere, but without that at least I think it would
be significantly worse. Others may have different opinions of course,
and are encouraged to express them :)


> For example:
> image1 => Gmail interface
> image2 => Mailing list view

For emails with lots of code snippets, which is pretty common on many
of our lists, I think you will find the opposite is true. The "gmail
way" may be easier in some ways for pure text emails (though I'm sure
that can be argued too).


> Is there any method to do this conversion?
>
> I tried replacing '>' to '| ' [image3]. And I think it is better than what is present. It will look better if we
changecolor and background color for quoted text. But for this we actually need something that will help us to convert
rawtext to good looking HTML same as markdown does. But in case of markdown the syntax is different. For example it
uses**text** for bold and gmail uses *text* for bold. 

I don't think we should change the *conents* of the email ever,
period. How much logic do you have in there to make sure you only
change > in the case that it's an actual quote, and not when it's used
for other things, like in a diff or just random text? gmail gets this
wrong on a regular basis, and gmail has a lot more developer resources
behind it to maintain their code than we do.

Highlighting it in different colors I can be OK with. But not changing
the contents.


//Magnus



Re: Email raw text to HTML

From
Jacob Champion
Date:
On Thu, Aug 4, 2022 at 7:04 AM Magnus Hagander <magnus@hagander.net> wrote:
>
> On Thu, Aug 4, 2022 at 11:55 AM Sahil Harpal <sahilharpal1234@gmail.com> wrote:
> >
> > Hello,
> > I am curious about how Gmail converts plain text (Raw data) mail into a beautiful interface. Is there any library
orsomething that will help us to transform plain text into HTML? 
> > I am aiming to represent text (email message body) as it is being displayed in any mailing services like gmail,
yahooor outlook. The motive is the text should be readable. It is not just about enclosing previous replies in the
blockquotetag but we can even handle bold, italic, bullets, tables etc. 
>
> As a regular user of gmail, I think that would be a bad way to go. I
> find gmails way of rendering emails is particularly bad when it comes
> to things like inline code snippets etc. For one, it insists on not
> using a monospace font...

Quick +1 here... I love Gmail, but for some threads I have to escape
it and pull up Thunderbird (which monospaces correctly) or jump to the
website. And I manually align parts of my mail for readability (e.g.
[1]). If the website adopted the same strategy as Gmail, I would be
sad.

--Jacob

[1] https://www.postgresql.org/message-id/55c7c8ef-8bc7-22ce-f240-dc3eaa14e34e@timescale.com