move html dump stuff into one file and customize

Fri, 05 May 2017 17:36:49 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Fri, 05 May 2017 17:36:49 -0400
changeset 564
81f1da7a57e1
parent 563
c1949730cc74
child 565
b559ab3fd0ce

move html dump stuff into one file and customize

.mutt/mailcap file | annotate | diff | comparison | revisions
.vimrc file | annotate | diff | comparison | revisions
bin/mutt-html2txt file | annotate | diff | comparison | revisions
--- a/.mutt/mailcap
+++ b/.mutt/mailcap
@@ -1,2 +1,2 @@
 # text/html; pandoc -S -t markdown-raw_html %s; copiousoutput; description=HTML Part; nametemplate=%s.html
-text/html; links -dump %s; copiousoutput; description=HTML Part; nametemplate=%s.html
+text/html; mutt-html2txt %s; copiousoutput; description=HTML Part; nametemplate=%s.html
--- a/.vimrc
+++ b/.vimrc
@@ -498,8 +498,7 @@ let g:neocomplcache_filename_include_exp
 
 " {{{ Commands
 " Preview markdown mail -- I edit with headers so I box them in a code block.
-command! MailPreview     enew | set bt=nofile | 0r # | exe 'norm 0O```<Esc>}O```' | silent exe '%!mutt-md2html > #.~htm~'
-                           \ | silent exe '0r !links -dump #.~htm~' | silent exe '!rm -f #.~htm~' | 0
+command! MailPreview     enew | set bt=nofile | 0r # | exe 'norm 0O```<Esc>}O```' | silent exe '%!mutt-md2html | mutt-html2txt' | 0
 command! MailPreviewHTML enew | set bt=nofile | 0r # | exe 'norm 0O```<Esc>}O```' | silent exe '%!mutt-md2html' | 0
 
 if !exists(":DiffOrig")
new file mode 100755
--- /dev/null
+++ b/bin/mutt-html2txt
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -eu
+
+LINKS="links -html-tables 0 -html-image-names 0 -html-margin 0"
+FILE=${1:--}
+
+[ "$FILE" != '-' ] &&
+  exec $LINKS -dump $FILE
+
+TMPHTML="$(mktemp).html"
+cat > $TMPHTML
+$LINKS -dump $TMPHTML
+rm -f $TMPHTML

mercurial