Annotation of pkgsrc/shells/mksh/files/FAQ2HTML.sh, revision 1.1
1.1 ! jperkin 1: #!/bin/mksh
! 2: rcsid='$MirOS: src/bin/mksh/FAQ2HTML.sh,v 1.1 2020/02/03 22:23:33 tg Exp $'
! 3: #-
! 4: # Copyright © 2020
! 5: # mirabilos <m@mirbsd.org>
! 6: #
! 7: # Provided that these terms and disclaimer and all copyright notices
! 8: # are retained or reproduced in an accompanying document, permission
! 9: # is granted to deal in this work without restriction, including un‐
! 10: # limited rights to use, publicly perform, distribute, sell, modify,
! 11: # merge, give away, or sublicence.
! 12: #
! 13: # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
! 14: # the utmost extent permitted by applicable law, neither express nor
! 15: # implied; without malicious intent or gross negligence. In no event
! 16: # may a licensor, author or contributor be held liable for indirect,
! 17: # direct, other damage, loss, or other issues arising in any way out
! 18: # of dealing in the work, even if advised of the possibility of such
! 19: # damage or existence of a defect, except proven that it results out
! 20: # of said person’s immediate fault when using the work as intended.
! 21: #-
! 22:
! 23: set -e
! 24: LC_ALL=C; LANGUAGE=C
! 25: export LC_ALL; unset LANGUAGE
! 26: nl='
! 27: '
! 28: srcdir=$(dirname "$0")
! 29:
! 30: p=--posix
! 31: sed $p -e q </dev/null >/dev/null 2>&1 || p=
! 32:
! 33: v=$1
! 34: if test -z "$v"; then
! 35: v=$(sed $p -n '/^#define MKSH_VERSION "\(.*\)"$/s//\1/p' "$srcdir"/sh.h)
! 36: fi
! 37: src_id=$(sed $p -n '/^RCSID: /s///p' "$srcdir"/mksh.faq)
! 38: # sanity check
! 39: case $src_id in
! 40: (*"$nl"*)
! 41: echo >&2 "E: more than one RCSID in mksh.faq?"
! 42: exit 1 ;;
! 43: esac
! 44:
! 45: sed $p \
! 46: -e '/^RCSID: \$/s/^.*$/&----/' \
! 47: -e 's!@@RELPATH@@!http://www.mirbsd.org/!g' \
! 48: -e 's&^ &<span style="display:none;"> </span>&' \
! 49: "$srcdir"/mksh.faq | tr '\n' '&' | sed $p \
! 50: -e 's&&g' \
! 51: -e 's&----&g' \
! 52: -e 's\([^]*\)\1g' \
! 53: -e 's\([^]*\)\1g' \
! 54: -e 's\([^]*&\)*ToC: \([^&]*\)&Title: \([^&]*\)\(&[^]*\)\{0,1\}</div>&<h2 id="\2"><a href="#\2">\3</a></h2>&<div>g' \
! 55: -e 's[^]*</div>&<div>g' \
! 56: -e 's^</div>&*' \
! 57: -e 's$</div>&' \
! 58: -e 's<><error><>g' \
! 59: -e 's&&g' | tr '&' '\n' >FAQ.tmp
! 60:
! 61: exec >FAQ.htm~
! 62: cat <<EOF
! 63: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
! 64: "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
! 65: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
! 66: <meta http-equiv="content-type" content="text/html; charset=utf-8" />
! 67: <title>mksh $v FAQ (local copy)</title>
! 68: <meta name="source" content="$src_id" />
! 69: <meta name="generator" content="$rcsid" />
! 70: <style type="text/css"><!--/*--><![CDATA[/*><!--*/
! 71: .boxhead {
! 72: margin-bottom:0px;
! 73: }
! 74:
! 75: .boxtext {
! 76: border:4px ridge green;
! 77: margin:0px 24px 0px 18px;
! 78: padding:2px 3px 2px 3px;
! 79: }
! 80:
! 81: .boxfoot {
! 82: margin-top:0px;
! 83: }
! 84:
! 85: h2:before {
! 86: content:"🔗 ";
! 87: }
! 88:
! 89: a[href^="ftp://"]:after,
! 90: a[href^="http://"]:after,
! 91: a[href^="https://"]:after,
! 92: a[href^="irc://"]:after,
! 93: a[href^="mailto:"]:after,
! 94: a[href^="news:"]:after,
! 95: a[href^="nntp://"]:after {
! 96: content:"⏍";
! 97: color:#FF0000;
! 98: vertical-align:super;
! 99: margin:0 0 0 1px;
! 100: }
! 101:
! 102: pre {
! 103: /* ↑ → ↓ ← */
! 104: margin:0px 9px 0px 15px;
! 105: }
! 106:
! 107: tt {
! 108: white-space:nowrap;
! 109: }
! 110: /*]]>*/--></style>
! 111: </head><body>
! 112: <p>Note: Links marked like <a href="irc://chat.freenode.net/!/bin/mksh">this
! 113: one to the mksh IRC channel</a> connect to external resources.</p>
! 114: <p>⚠ <b>Notice:</b> the website will have <a
! 115: href="http://www.mirbsd.org/mksh-faq.htm">the latest version of the
! 116: mksh FAQ</a> online.</p>
! 117: <h1>Table of Contents</h1>
! 118: <ul>
! 119: EOF
! 120: sed $p -n \
! 121: '/^<h2 id="\([^"]*"\)><a[^>]*\(>.*<\/a><\/\)h2>$/s//<li><a href="#\1\2li>/p' \
! 122: <FAQ.tmp
! 123: cat <<EOF
! 124: </ul>
! 125:
! 126: <h1>Frequently Asked Questions</h1>
! 127: EOF
! 128: cat FAQ.tmp - <<EOF
! 129: <h1>Imprint</h1>
! 130: <p>This offline HTML page for mksh $v was automatically generated
! 131: from the sources.</p>
! 132: </body></html>
! 133: EOF
! 134: exec >/dev/null
! 135: rm FAQ.tmp
! 136: mv FAQ.htm~ FAQ.htm
CVSweb <webmaster@jp.NetBSD.org>