]> git.madduck.net Git - etc/mutt.git/blob - .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:

add markup=markdown to content-type
[etc/mutt.git] / .mutt / htmldump
1 #!/bin/sh
2
3 get_mutt_confvar() {
4   local ret;
5   ret=$(mutt -D | sed -rne "s,^${1}(=| 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 elinks >/dev/null; then
31
32   exec elinks -anonymous -localhost -eval "set document.codepage.assume = '$2'" \
33     -dump-width $WIDTH \
34     -eval "set document.browse.margin_width = 0" \
35     -force-html -dump -dump-charset utf-8 -dump-color-mode 0
36
37 elif command -v w3m >/dev/null; then
38
39   exec w3m -I "$2" -O utf-8 -T text/html -dump -cols $WIDTH
40
41 else
42
43   echo >&2 No HTML to text converter found.
44   exit 1
45
46 fi