#! /bin/sh # # ll2mml --- 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). # # Oct 1992: expand tabs to fix awk scripts u='Usage: ll2mml ' case $# in 0 ) echo "$u" 1>&2 ; exit ;; esac # Print the prologue: cat << 'eof' " > " > 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. expand $* | awk '/\* \* \* \*/ { exit } { print } ' | quote | framechars | awk 'BEGIN { mode = 0 } /^The Language List/ && (mode==0) { printf "\n\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>. expand $* | 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. expand $* | awk '/APPENDIX/ { app = 1 } (app==1) { print } ' | quote | sed 's/[ ]*$//' | 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