Permalink
Browse files

mancx: revive for updated formatting on man.cx

  • Loading branch information...
1 parent 690a725 commit e44b4bc48fddb4a186044adb82134a588ddcae6d @falconindy committed Jul 30, 2011
Showing with 13 additions and 5 deletions.
  1. +13 −5 mancx
View
18 mancx
@@ -6,9 +6,8 @@
#
BASEURL='http://man.cx'
-XMLLINT='xmllint --html'
-XPATH_EXPR='//*[@id="manpage"]/*[self::pre or self::h3]'
-DETAG='$d;s|</\?[^>]\+>||g;s|&lt\;|<|g;s|&gt\;|>|g'
+XMLLINT=('xmllint' '--html')
+XPATH_EXPR='//*[@id="manpage"]'
usage() {
printf "Usage: %s [section] manpage" "${0##*/}" >&2
@@ -36,5 +35,14 @@ esac
# if found locally, exit
man ${SECTION//[^[:digit:]]/} $PAGE 2>/dev/null && exit
-manpage=$(curl -s $BASEURL/$PAGE$SECTION | $XMLLINT --xpath "$XPATH_EXPR" - 2>/dev/null | sed "$DETAG" | colorify)
-[[ $manpage ]] && "${PAGER:-less}" <<< "$manpage" || printf "No mancx entry for %s\n" "$PAGE"
+manpage=$(curl -s $BASEURL/$PAGE$SECTION |
+ "${XMLLINT[@]}" --xpath "$XPATH_EXPR" - 2>/dev/null |
+ w3m -T text/html |
+ colorify)
+
+if [[ $manpage ]]; then
+ "${PAGER:-less}" <<< "$manpage"
+else
+ printf "No mancx entry for %s\n" "$PAGE"
+ exit 1
+fi

0 comments on commit e44b4bc

Please sign in to comment.