Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

mancx: revive for updated formatting on man.cx

  • Loading branch information...
commit e44b4bc48fddb4a186044adb82134a588ddcae6d 1 parent 690a725
@falconindy authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.