# Neomutt ## Markdown to HTML rendering To write more normie-friendly emails, non-plain-text emails are probably better. For this, a conversion from Markdown to HTML with Mathjax support seems best. It supports all the bells and whistles of markdown (images, links, code, italics, bold) as well as mathemtical formulas in LaTex notation using Mathjax. ### Configuration The conversion is done via pandoc using templates. Ensure `pandoc` is installed. (`which pandoc || sudo pacman -S pandoc`) Add to your muttrc (either in `~/.mutt/muttrc` or `~/.config/mutt/muttrc`. From now on assuming `~/.config/mutt` as config folder) ``` macro compose m \ "set pipe_decode\ pandoc -f gfm -t plain -o /tmp/msg.txt\ pandoc -s --self-contained -o /tmp/msg.html --resource-path ~/.config/mutt/templates/ --template email\ unset pipe_decode\ /tmp/msg.txt\ /tmp/msg.html\ " \ "Convert markdown to HTML5 and plaintext alternative content types" ``` Create a folder called `templates`: `mkdir -p ~/.config/mutt/templates` and create a file called `email.html` in this folder with the following content: ```html $for(css)$ $endfor$ $for(header-includes)$ $header-includes$ $endfor$ $body$ $for(include-after)$ $include-after$ $endfor$ ``` ### Usage To use this, write your email as usual and afterwards, press `m` on the created file in neomutt. This will generate a combined file for plaintext fallback in case of unsupported HTML rendering. For now, also delete the still present plaintext file with `D`. Your email should now be ready to be sent. For writing formulas, just use latex syntax in the normal `$` delimiters. Be careful on inline formulas, here a whitespace between the leading `$` and the formula breaks the rendering! ## File Size Since Mathjax is creating a binary for the rendering of the math syntax which is embedded in the html, the file sizes are usually around 1 MB. This is not necessary when no LaTeX syntax is used. Create a second macro for which you use a different template, that excludes the mathjax script. This way you can create smaller emails with pure markdown syntax and when necessary can send mathematical formulas, resulting in larger mails. For this add the following to the muttrc: ``` macro compose l \ "set pipe_decode\ pandoc -f gfm -t plain -o /tmp/msg.txt\ pandoc -s --self-contained -o /tmp/msg.html --resource-path ~/.config/mutt/templates/ --template email_pure\ unset pipe_decode\ /tmp/msg.txt\ /tmp/msg.html\ " \ "Convert markdown to HTML5 and plaintext alternative content types" ``` Further create a new file called `email_pure.html` in `mutt/templates` with the following content: ```html $for(css)$ $endfor$ $for(header-includes)$ $header-includes$ $endfor$ $body$ $for(include-after)$ $include-after$ $endfor$ ``` TODO: delete plaintext attachment after HTML creation TODO: remove `tmp` files after sending