Mon, 06 Jan 2020 15:34:34 -0600
proper multipart!
846 | 1 | #!/bin/sh |
2 | set -eu | |
3 | ||
4 | output=$1 | |
5 | ||
6 | # Output directory is going to be one-per-process. I'd like to have a fully | |
7 | # random tmpdir but doing that and having it mutt clean up is "hard". Note | |
8 | # that when these two parts get attached, we can't just clean files inside the | |
9 | # macro, because they aren't read into memory until send/save. | |
10 | ||
11 | mkdir -p $output | |
12 | ||
13 | # Store stdin because we're using it twice. | |
14 | cat - > $output/msg.orig | |
15 | ||
16 | # Noting the above, there may be old output here. pandoc likes to confirm | |
17 | # overwrites so we handle it. | |
18 | rm -f $output/msg.{txt,html} | |
19 | ||
20 | pandoc \ | |
21 | --quiet \ | |
22 | -f markdown-blank_before_blockquote+smart \ | |
23 | -t plain \ | |
24 | -o $output/msg.txt \ | |
25 | $output/msg.orig | |
26 | ||
27 | pandoc \ | |
28 | --quiet \ | |
29 | --standalone \ | |
30 | -f markdown-blank_before_blockquote+smart \ | |
31 | -t html5 \ | |
32 | --self-contained \ | |
33 | --template=mail \ | |
34 | --highlight-style=monochrome \ | |
35 | --email-obfuscation=none \ | |
36 | -o $output/msg.html \ | |
37 | $output/msg.orig |