home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sources.misc
- From: oscar@cui.unige.ch (" (Oscar Nierstrasz)")
- Subject: v30i015: langmml - turn The Language List into a Framemaker document, Part01/01
- Message-ID: <1992May23.175007.17027@sparky.imd.sterling.com>
- X-Md4-Signature: c09795adf007bf6e96522b6895e3e117
- Date: Sat, 23 May 1992 17:50:07 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: oscar@cui.unige.ch (Oscar Nierstrasz)
- Posting-number: Volume 30, Issue 15
- Archive-name: langmml/part01
- Environment: Framemaker
-
- langmml is a shell script that generates a Framemaker MML document
- from The Language List -- a list of all known programming languages
- regularly posted on comp.lang.misc. The List is a plain ascii file.
- The script generates a prettier version of the same document.
- There are two subscripts used by langmml -- framechars and quote --
- which are also included.
-
- Oscar Nierstrasz
-
- #! /bin/sh
- # This is a shell archive. The files and directories it contains
- # may be unpacked by running it through /bin/sh.
- # Packaged by oscar at cuisun48 on Sat May 2 17:32:29 MET DST 1992
- # Contents:
- # -rwxr-xr-x 1 oscar 4021 May 2 17:31 langmml
- # -rwxr-xr-x 1 oscar 257 May 2 17:15 framechars
- # -rwxr-xr-x 1 oscar 905 May 2 17:15 quote
- if test -f langmml
- then echo 'shar: langmml -- file exists'
- else echo x - langmml
- sed 's/^|//' > langmml << 'eof'
- |#! /bin/sh
- |#
- |# langmml --- generate MML file from The Language List
- |#
- |# Uses: quote framechars
- |#
- |# Author: Oscar Nierstrasz (oscar@cui.unige.ch) May 1992
- |#
- |# The Language List is regularly posted on comp.lang.misc.
- |# This shell script generates a FrameMaker MML file from the List
- |# that can be loaded into a Framemaker document, thus producing
- |# a prettier, more readable version of the list for printing out.
- |# Language names are shown in bold.
- |#
- |# Heuristics have been tailored for Version 1.7 of the List.
- |# You must define paragraph tags for Title, SubTitle, Body, Note, Lang
- |# and Sub for the document template that you will use.
- |#
- |# Suggestions:
- |# Title is for the document title (big, bold & centred).
- |# Subtitle is for the List itself and the appendices (bold & centred).
- |# Body is an ordinary paragraph.
- |# Note is a subsection heading (bold, italic).
- |# Lang is a language entry (first-line left-indented).
- |# Sub is a sub-entry for homonymic languages (indented).
- |
- |u='Usage: langmml <langlist>'
- |
- |case $# in
- |0 ) echo "$u" 1>&2 ; exit ;;
- |esac
- |
- |# Print the prologue:
- |
- |cat << 'eof'
- |<MML file -- generated by `langmml'>
- |<Units pica>
- |<!DefineTag Title>
- |<!DefineTag SubTitle>
- |<!DefineTag Body>
- |<!DefineTag Note>
- |<!DefineTag Lang>
- |<!DefineTag Sub>
- |<Comment -- linefeed = hard return>
- |<!DefineMacro lf "\\x0d " >
- |<!DefineMacro cr "\\x0a " >
- |<!DefineMacro endash "<Character \\xd0 >" >
- |<!DefineMacro emdash "<Character \\xd1 >" >
- |eof
- |
- |# INTRODUCTION
- |
- |# Process the introduction.
- |# Try to guess which lines are supposed to be broken, and
- |# which can be justified. Mode 0 means the previous line was blank.
- |# Mode 1 means we are inside a justified paragraph. Mode 2 means we
- |# are inside a list.
- |
- |awk '/\* \* \* \*/ { exit }
- | { print } ' $* | \
- |quote | \
- |framechars | \
- |awk 'BEGIN { mode = 0 }
- |/^The Language List/ && (mode==0) {
- | printf "\n<Title>\n%s", $0 ; mode = 1 ; next }
- |/^[A-Z].*: / && (mode==0) { printf "\n<Body>\n%s", $0 ; mode = 2 ; next }
- |/^[A-Z].*:$/ && (mode==0) { printf "\n<Note>\n%s", $0 ; mode = 2 ; next }
- |/^[A-Z]/ && (mode==0) { printf "\n<Note>\n%s", $0 ; mode = 2 ; next }
- |/^ / && (mode==0) { printf "\n<Body>\n%s", $0 ; mode = 1 ; next }
- |/^ / && (mode==1) { printf "<lf>\\\n%s", $0 ; next }
- |/^./ && (mode==1) { printf "\n%s", $0 ; next }
- |/^./ && (mode==2) { printf "<lf>\\\n%s", $0 ; next }
- |/^$/ { print ; mode = 0 }' | sed 's/^ *//'
- |
- |# BODY
- |
- |# Process the list itself.
- |# Embold the name of each language. (Occurring on the first line
- |# of a paragraph before " - ".) Homonyms are listed as a separate
- |# paragraph called <Sub>.
- |
- |awk '(NR==1),/\* \* \* \*/ { next }
- |/APPENDIX/ { exit }
- | { print } ' $* | \
- |quote | \
- |framechars | \
- |awk 'BEGIN { print "\n<SubTitle>The Language List" ; mode = 0 }
- |/^ *[0-9]*\. / && (mode==0) {
- | n = index($0,". ")
- | printf "\n<Sub>\n%s", $0
- | mode = 1 ; next }
- |/ -$/ && (mode==0) {
- | printf "\n<Lang><Bold>%s<Plain> <emdash>", substr($0,0,length-2)
- | mode = 1 ; next }
- |/ - / && (mode==0) {
- | n = index($0," - ")
- | printf "\n<Lang><Bold>%s<Plain> <emdash>", substr($0,0,n-1)
- | printf "\n%s", substr($0,n+3)
- | mode = 1 ; next }
- |/^[a-z]*: / || /^ftp [a-z ]*:/ {
- | n = index($0,": ")
- | printf "<lf>\\\n<Italic>%s:<Plain>", substr($0,0,n-1)
- | printf "\n%s", substr($0,n+2)
- | next }
- |/./ { printf "\n%s", $0 ; next }
- |/^$/ { print ; mode = 0 }' | sed 's/^ *//'
- |
- |# APPENDIX
- |
- |# Process the appendices.
- |# Again, try to guess where lines are supposed to be broken.
- |# Mode 3 means we are building up the subtitle.
- |
- |awk '/APPENDIX/ { app = 1 }
- |(app==1) { print } ' $* | \
- |quote | \
- |framechars | \
- |awk 'BEGIN { mode = 0 }
- |/^APPENDIX/ { printf "\n<SubTitle>%s", $0 ; mode = 3 ; next }
- |/^$/ && (mode==3) { next }
- |/./ && (mode==3) { printf "<lf>\\\n%s", $0 ; mode = 0 ; next }
- |/^==*$/ { next }
- |/^19[0-9][0-9] / && (mode==0) {
- | printf "\n<Body>%s", $0 ; mode = 2 ; next }
- |/./ && (mode==0) { printf "\n<Body>%s", $0 ; mode = 1 ; next }
- |/./ && (mode==1) { printf "\n%s", $0 ; next }
- |/./ && (mode==2) { printf "<lf>\\\n%s", $0 ; next }
- |/^$/ { print ; mode = 0 }' | sed 's/^ *//'
- |
- |exit
- |
- eof
- if test `wc -c < langmml` -ne 4021
- then echo 'shar: langmml damaged (should be 4021 bytes)'
- fi
- fi
- if test -f framechars
- then echo 'shar: framechars -- file exists'
- else echo x - framechars
- sed 's/^|//' > framechars << 'eof'
- |#! /bin/sed -f
- |#
- |# framechars --- escape ascii characters with special meaning for Frame
- |#
- |# Author: Oscar Nierstrasz oscar@cui.unige.ch (920502)
- |s/\\/&&/g
- |s/ /\\t/g
- |s/[<>]/\\&/g
- |s/--/<Character \\xd0 >/g
- |s/``/<Character \\xd2 >/g
- |s/''/<Character \\xd3 >/g
- eof
- if test `wc -c < framechars` -ne 257
- then echo 'shar: framechars damaged (should be 257 bytes)'
- fi
- fi
- if test -f quote
- then echo 'shar: quote -- file exists'
- else echo x - quote
- sed 's/^|//' > quote << 'eof'
- |#! /bin/awk -f
- |#
- |# quote --- convert double quotes to matched pairs of single quotes
- |#
- |# Correctly handles multi-line quotes.
- |# Tries to protect double quotes within equations, but
- |# will probably screw up for multi-line equations with quotes.
- |#
- |# Author: Oscar Nierstrasz @ utcsrgv!oscar 840529
- |# 881222: fixed handling of umlauts (\")
- |
- |BEGIN { FS = "\""
- | q[0] = "``"
- | q[1] = "''"
- | j = 0
- | }
- |
- |/^\.EQ/,/^\.EN/ { print ; next }
- |/^\./ { print ; next }
- |
- |/\"/ { if ($0 ~ /\$/) {
- | n = split ($1, eq, "$") + 1
- | k = n % 2
- | printf "%s", $1
- | for (i=2; i<=NF; i++) {
- | if (k == 0)
- | printf "%s%s", q[j], $i
- | else printf "\"%s", $i
- | j = 1-j
- | n = k + split ($i, eq, "$") + 1
- | k = n % 2
- | }
- | printf "\n"
- | }
- | else {
- | for (i=1; i<NF; i++) {
- | if ($i ~ /\\$/)
- | printf "%s\"", $i
- | else {
- | printf "%s%s", $i, q[j]
- | j = 1-j
- | }
- | }
- | printf "%s", $NF
- | printf "\n"
- | }
- | next
- | }
- |
- |{ print }
- |
- eof
- if test `wc -c < quote` -ne 905
- then echo 'shar: quote damaged (should be 905 bytes)'
- fi
- fi
- exit
-
- -------------------------------------------------------------------
- Dr. O.M. Nierstrasz | Tel: 41 (22) 787.65.80
- Centre Universitaire d'Informatique | Fax: 735.39.05
- (University of Geneva) | Home: 733.95.68
- 12 rue du Lac, CH-1207 Geneva | E-mail: oscar@cui.unige.ch
- SWITZERLAND | oscar@cgeuge51.bitnet
- -------------------------------------------------------------------
- AFTER SEPT 1992:
- -------------------------------------------------------------------
- Dr. O.M. Nierstrasz | Tel: 41 (22) 705.71.11
- Centre Universitaire d'Informatique | Fax: 320.29.27
- University of Geneva | Home: 733.95.68
- 24, rue du General-Dufour |
- CH-1211 Geneva 4 | E-mail: oscar@cui.unige.ch
- SWITZERLAND | oscar@cgeuge51.bitnet
- -------------------------------------------------------------------
-
-
- exit 0 # Just in case...
-