1

In mutt, I'm trying to write formatted emails, but the pre-processing step that converts markdown to HTML is mangling the previous messages.

I'm using this answer to convert my messages to HTML.

In mutt, I can write a message literally like this:

Dear A

# Summary of changes

1. Item 1
2. Item 2

B

and it ends up formatted as you'd expect. A sees B's well-formatted html.

Unfortunately, this mangles the reply thread, since markdown uses whitespace differently than the sender probably did. In addition the reply thread is rendered to white-space+text, rather than retaining markdown/html markup.

To see this, if B replies using the Mutt/HTML/Markdown tricks, pandoc will interpret the quoted text strangely, and mangle the reply text.

The result after B->A->B looks like (I had to edit a bit to remove emails and such, but the it's basically spot on)

A,
You mangled my reply, you twit, people do read the chain sometimes, you know

--B                                                                                                                            
                                                                                                                                     
On Tue, May 4, 2021, 3:49 PM A <a> wrote:                                                           
                                                                                                                                     
> B,
> I can do that too!                                                                                                                     
> With formatting!                                                                                                                   
>                                                                                                                                    
>    1. One-again                                                                                                                    
>    2. Two-again                                                                                                                    
> --A                                                                                                                                   
> On Tue, May 04, 2021 at 03:48:21PM -0700, B <b> wrote: >                                                             
> > Summary of Changes > > > 1. Item 1 > > 2. Item 2 > > > >                                                              
>                                                                                                                                    
                                  

Question

Is it possible (and how can I) edit in markdown, convert my message to HTML, and either attach prev replies unchanged, or (ideally) in-line previous replies unchanged.

3
  • I appreciate the irony of complaining about mangled reply chains while top-posting. But, in short: 1. you can't stop other people mangling stuff in their replies. 2. un-mangling stuff after it has been mangled is extremely difficult to do reliably. 3. why not just send plaint-text/markdown emails wrapped in <pre> and </pre>? - HTML doesn't belong in email, anyway :-)
    – cas
    Commented May 5, 2021 at 6:37
  • Sorry, my question wasn't clear. For (1) and (2), the issue is I want to be a good citizen and not mangle others' replies. I can't help what they did, as you say. I'll edit. Commented May 5, 2021 at 15:37
  • And to address (3), you're right, this probably is not worth it. Commented May 5, 2021 at 15:39

1 Answer 1

0

The solution is to use pandoc as the auto html viewer. Pandoc would then spit out the original html message in proper markdown.

In your mailcap file (stolen from here) :

text/html; pandoc -f html -t markdown -i %s; nametemplate=%s.html; needsterminal; copiousoutput:

The idea is that if you use pandoc to read and format the message, it will render out markdown whitespace in such a way that it can be read back into html later.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .