]> git.madduck.net Git - etc/mutt.git/blob - .config/mutt/htmldump

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

text/calendar is not actually a desirable alternative
[etc/mutt.git] / .config / mutt / htmldump
1 #!/bin/sh
2
3 get_mutt_confvar() {
4   local ret;
5   ret=$(mutt -Q "$1" | sed -rne "s,\S+(=| is ),,p")
6   case "$ret" in
7     (set) echo return 0;;
8     (unset) echo return 1;;
9     ('') echo "${2:-}"; return 1;;
10     (*) echo "$ret";;
11   esac
12 }
13
14 WRAP=$(get_mutt_confvar wrap 0)
15 if [ $WRAP -lt 0 ]; then
16   WIDTH=$((${COLUMNS:-78} + $WRAP))
17
18 elif [ $WRAP -gt 0 ]; then
19   WIDTH=$WRAP
20
21 fi
22
23 if command -v html2markdown >/dev/null; then
24
25   exec html2markdown --asterisk-emphasis --body-width=$WIDTH --unicode-snob \
26     --no-skip-internal-links --links-after-para --no-wrap-links \
27     --decode-errors=replace --images-to-alt - "$2"| \
28     sed -re 's,^\\--[[:space:]]+$,-- ,'
29
30 elif command -v pandoc >/dev/null; then
31
32   exec iconv -f "$2" -t utf-8 | pandoc -s -f html -t markdown_mmd \
33     --columns=$WIDTH
34
35 elif command -v elinks >/dev/null; then
36
37   exec elinks -anonymous -localhost -eval "set document.codepage.assume = '$2'" \
38     -dump-width $WIDTH \
39     -eval "set document.browse.margin_width = 0" \
40     -force-html -dump -dump-charset utf-8 -dump-color-mode 0
41
42 elif command -v w3m >/dev/null; then
43
44   exec w3m -I "$2" -O utf-8 -T text/html -dump -cols $WIDTH
45
46 else
47
48   echo >&2 No HTML to text converter found.
49   exit 1
50
51 fi