# HG changeset patch # User Lucas Levrel # Date 1450904555 -3600 # Node ID eecec1b9437aeed52d1e8779ec58da9773bb0d92 # Parent cca198d5952c2c62d14f8afaa84803b8fea79491 New man command diff -r cca198d5952c -r eecec1b9437a rootfs/usr/bin/man --- a/rootfs/usr/bin/man Thu Dec 03 04:59:59 2015 +0200 +++ b/rootfs/usr/bin/man Wed Dec 23 22:02:35 2015 +0100 @@ -10,24 +10,60 @@ . /etc/locale.conf export TEXTDOMAIN LANG -check_retawq() { - if [ ! -x /usr/bin/retawq ]; then - echo; _ "Missing Retawq web browser..." - _ 'Please run: %s' "su -c 'tazpkg get-install retawq'" - exit 0 +display_html() { + if [ -x /usr/bin/retawq ]; then + retawq --dump=file://"$1" | less -M + else + # Rationale: busybox "less" is unable to use control chars, so we're + # stuck with regular text (no bold, colors...), and use other ways to + # emphasis: quotes, underscores, brackets, tabs. + # Explanation for following sequence: + # 1) keep only what's in the HTML body + # 2) make sure
 and 
are on a line of their own (see 3) + # 3a) newlines must be obeyed between
 tags, so explicitly add 
+ # because newlines are going to be stripped; also remove (added + # emphasis characters would be misleading) + # 3b) the
line is matched also, but should not get a
added, + # so remove it (let it on the
 line, starts a new paragraph)
+		# 4) strip newlines, remove comments (should be done earlier)
+		# 5) emphasize headers and titles with a Tab, add newline after
+		# 6) add newline for 

+ # 7) suppress and some other tags + # 8) add newline and hyphen for list items, newline for list end + # 9) emphasize and blocks by ‘’ ; by _ + # 10) render x-details between brackets [] + # 11) remove start-of-line and end-of-line spaces + # 12) render HTML-encoded chars + # 13) wrap at word boundaries + cat "$1" | sed '1,//d; /<\/body>/d' \ + | sed -r 's!(.)<(/?)pre>!\1\n<\2pre>!g; s!<(/?)pre>(.)!<\1pre>\n\2!g;' \ + | sed -r '/
/,/<\/pre>/{s!$!
!g; s!!!g}; \ + /<\/pre>/s!
$!!' | tr '\n' ' ' \ + | sed -r 's%%%g; \ + s!<(header|h[1-4])>! !g; s!