]> 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:

htmldump debugging
[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 awesome-client <<-_eof
24         local naughty = require("naughty")
25         naughty.notify({ preset = naughty.config.presets.low,
26             title  = "htmldump called",
27             text   = [[$@]],
28             })
29         _eof
30
31 if command -v html2markdown >/dev/null; then
32
33   exec html2markdown --asterisk-emphasis --body-width=$WIDTH --unicode-snob \
34     --no-skip-internal-links --links-after-para --no-wrap-links \
35     --decode-errors=replace --images-to-alt - "$2"| \
36     sed -re 's,^\\--[[:space:]]+$,-- ,'
37
38 elif command -v pandoc >/dev/null; then
39
40   exec iconv -f "$2" -t utf-8 | pandoc -s -f html -t markdown_mmd \
41     --columns=$WIDTH
42
43 elif command -v elinks >/dev/null; then
44
45   exec elinks -anonymous -localhost -eval "set document.codepage.assume = '$2'" \
46     -dump-width $WIDTH \
47     -eval "set document.browse.margin_width = 0" \
48     -force-html -dump -dump-charset utf-8 -dump-color-mode 0
49
50 elif command -v w3m >/dev/null; then
51
52   exec w3m -I "$2" -O utf-8 -T text/html -dump -cols $WIDTH
53
54 else
55
56   echo >&2 No HTML to text converter found.
57   exit 1
58
59 fi