X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/812b526d127c6657e571db8b33a58137af6709cd..598b07b7de7559ddcaed4063912f68bf951d6701:/scripts/htmlman diff --git a/scripts/htmlman b/scripts/htmlman index 21452dc..5290d1b 100755 --- a/scripts/htmlman +++ b/scripts/htmlman @@ -1,7 +1,7 @@ #! /bin/sh # # This file is part of DisOrder -# Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell +# Copyright (C) 2004, 2005, 2007, 2008, 2010 Richard Kettlewell # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,52 +20,67 @@ set -e stdhead=false +extension="html" while test $# -gt 0; do case "$1" in -stdhead ) stdhead=true ;; + -extension ) + shift + extension=$1 + ;; + -- ) + shift + break + ;; -* ) echo >&2 "ERROR: unknown option $1" exit 1 ;; * ) break + ;; esac shift done -title=$(basename $1) - -echo "" -echo " " -if $stdhead; then - echo "@quiethead@#" -fi -echo " $title" -echo " " -echo " " -if $stdhead; then - echo "@stdmenu{}@#" -fi -printf "
"
-# this is kind of painful using only BREs
-nroff -Tascii -man "$1" | ${GNUSED} \
-                      '1d;$d;
-                       1,/./{/^$/d};
-                       s/&/\&/g;
-                       s//\>/g;
-                       s/@/\@/g;
-                       s!\(.\)\1!\1!g;
-                       s!\(&[#0-9a-z][0-9a-z]*;\)\1!\1!g;
-                       s!_\(.\)!\1!g;
-                       s!_\(&[#0-9a-z][0-9a-z]*;\)!\1!g;
-                       s!<\1>!!g'
-echo "
" -if $stdhead; then - echo "@credits" -fi -echo " " -echo "" +for page; do + title=$(basename $page) + output=$(basename $page).$extension + echo "$page -> $output" >&2 + exec > $output.new + echo "" + echo " " + if $stdhead; then + echo "@quiethead@#" + fi + echo " $title" + echo " " + echo " " + if $stdhead; then + echo "@stdmenu{}@#" + fi + printf "
"
+  # this is kind of painful using only BREs
+  nroff -Tascii -man "$page" | ${GNUSED} \
+                        '1d;$d;
+                         1,/./{/^$/d};
+                         s/&/\&/g;
+                         s//\>/g;
+                         s/@/\@/g;
+                         s!\(.\)\1!\1!g;
+                         s!\(&[#0-9a-z][0-9a-z]*;\)\1!\1!g;
+                         s!_\(.\)!\1!g;
+                         s!_\(&[#0-9a-z][0-9a-z]*;\)!\1!g;
+                         s!<\1>!!g'
+  echo "
" + if $stdhead; then + echo "@credits" + fi + echo " " + echo "" + mv $output.new $output +done