neomutt: Rename render-prettyhtml to neomutt-renderhtml
Also ensure the temporary file a) is always different, by using mktemp and b) is always deleted with an EXIT trap
This commit is contained in:
parent
6b2a0e1918
commit
79a9c4a227
2 changed files with 6 additions and 4 deletions
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# render html as markdown and display in glow, supports syntax highlighting
|
||||
# requires: html2text, glow or bat
|
||||
# author: CEUK
|
||||
fpath=/tmp/mutt.md
|
||||
|
||||
perl -0777pe 's/(<code class="sourceCode\s?)(\w+?)(">)(.*?)(<\/code>)/\1\2\3\n```\2\n\4\n```\n\5/gs' "$1" | html2text | sed -re 's/^\s+(```(\w+)?)/\1/gm' -e 's/\x1b\[[6-9;]*m//g' >"$fpath"
|
||||
|
||||
if command -v bat >/dev/null 2>&1; then
|
||||
bat "$fpath"
|
||||
elif command -v glow >/dev/null 2>&1; then
|
||||
glow -s ~/.config/glow/email.json "$fpath"
|
||||
else
|
||||
sed 's/\x1b\[[6-9;]*m//g' <"$fpath"
|
||||
fi
|
||||
|
||||
rm "$fpath" || exit 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue