hzdg / django-mailmate

Define emails with classes and use templates for HTML emails.
http://django-mailmate.readthedocs.org
Other
5 stars 3 forks source link

Add Option for Automatically Generating Non-HTML Version #1

Closed matthewwithanm closed 10 years ago

matthewwithanm commented 12 years ago

If you only provide an html template, TemplatedEmailMessage should be able to generate a plain text version. Stripping tags would be a simple way to do this. Something more complicated (for example, converting to markdown) would be awesome.

matthewwithanm commented 12 years ago

Here's a project that would do the markdownification work for us: https://github.com/aaronsw/html2text

If we're worried about dependencies, it's just one (GPL) file so we could easily bundle it with emailtools.

lettertwo commented 12 years ago

The opposite might be cool, too (write the document in markdown)

cwood commented 12 years ago

Yea markdown would be nicer. How about styling it?

matthewwithanm commented 12 years ago

@eric That would be cool, but I don't know if it should be part of emailtools. There are probably already ways to render markdown templates into HTML for views. We should just make sure that emailtools allows the use of those, IMO.

@colin Styling what? I'm talking about a plaintext version so no styling allowed for that.

kkubasik commented 12 years ago

I dunno if bundling with a GPL licensed file is as easy as that, I'm pretty sure we have to have a compatible license...

That said, I'm not sure I'm a huge fan of converting to markdown as opposed to just stripping text. I think in some simple cases it will work well, but what about the far more complicated layouts? (Not uncommon) might we get some very odd results? At the least, I think the conversion should default to non-markdown and allow the user to request a markdown version...

Just my thoughts.

cwood commented 12 years ago

@matthewwithanm I assume with the markdown we would convert it to HTML. So we would need to style it. I thought we did inlines for all of that. But if its just plain text I would guess we would just parse it out. But we might run into issues with what @kkubasik said about more complex layouts.

matthewwithanm commented 12 years ago

@kkubasik Yeah, we would need a compatible license, but that doesn't seem like too big of a hurdle. If it is, I'm sure we could find another utility. For complicated layouts, I would think that you won't be able to rely on the automatic conversion and will need to create a plaintext template. strip_tags(html2text(html)) seems like a pretty sensible default for emails that only have an HTML template.

@cwood I'm not talking about converting from markdown to HTML (though @lettertwo was). I'm talking about the reverse. Basically, I have a simple html template that may have a few links or something. I don't want to have to create a separate template that duplicates it without the tags and stuff—that should just be generated from the html template. The easiest way to do it would be to just use django.utils.html.strip_tags, but if we used html2text we would be able to retain some of the meaning (like headings and links).

talebbits commented 12 years ago

Have we decided which one we are going to use ? django.utils.html.strip_tags or html2text I think we can use this django.utils.html.strip_tags if license is an issue?

matthewwithanm commented 12 years ago

I opened aaronsw/html2text#41 to find out about licensing. Hopefully he'll respond soon.