# Convert HTML markup to LaTex "book" format
#
# See html_clean.sed which should be run first
#
# This stuff just for W3 book -- hate those horizontal lines
s/________________________*//g
# Concatenate lines ending after /,/<.[Xx][Mm][Pp]>/b lit
/<.[Xx][Mm][Pp]>/b lit
/<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/,/<.[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/b lit
/<.[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>/b lit
/<[Pp][Rr][Ee]>/,/<.[Pp][Rr][Ee]>/b pre
/<.[Pp][Rr][Ee]>/b pre
#
############################################################## NORMAL
# Character conversions
s?\\?\\char'134 ?g
# From now on all backslashes are TeX backslashes.
s?{?\\{?g
s?}?\\}?g
s?%?\\%?g
s?&?\\\&?g
s?~?\\~?g
#s?\^?\\^?g
s?\^?{\\char94}?g
s?\[?\\lbrack ?g
s?\]?\\rbrack ?g
s?_?\\_?g
s?\$?\\$?g
# TeX Macro paramter needs protection
s?#?\\#?g
# Stuff to ignore
s?<[Ii][Ss][Ii][Nn][Dd][Ee][Xx]>??
s?[Aa][Dd][Dd][Rr][Ee][Ss][Ss]>??g
s?<[Nn][Ee][Xx][Tt][Ii][Dd][^>]*>??g
#
# Document Header stuff replaced once at top of document
#
s?<[Hh][Ee][Aa][Dd]>??g
s?[Hh][Ee][Aa][Dd]>??g
s???g
s?<[Bb][Oo][Dd][Yy]>??g
s?[Bb][Oo][Dd][Yy]>??g
s?<[Tt][Ii][Tt][Ll][Ee]>?\\author{Generated from the Hypertext}\\title{?g
s?[Tt][Ii][Tt][Ll][Ee]>?} \\maketitle \\cleardoublepage \\pagenumbering{roman} \\setcounter{page}{1} \\tableofcontents \\cleardoublepage \\pagenumbering{arabic} \\setcounter{page}{1}?g
s?<[Aa][Dd][Dd][Rr][Ee][Ss][Ss]>??g
s?[Aa][Dd][Dd][Rr][Ee][Ss][Ss]>??g
s?<[Nn][Ee][Xx][Tt][Ii][Dd][^>]*>??g
# Paragraph breaks
s?<[Pp]>?\\par ?g
#
# Headings.
#
s?<[Hh]n>?\\part{?g
s?[Hh]n>?}?g
s?<[Hh]1>?\\chapter{?g
s?[Hh][0-9]>?}?g
s?<[Hh]2>?\\section{?g
s?<[Hh]3>?\\subsection{?g
s?<[Hh]4>?\\subsubsection{?g
s?<[Hh]5>?\\paragraph{?g
s?<[Hh]6>?\\subparagraph{?g
#
# Lists
#
s?<[UuOo][Ll]>?\\begin{itemize}?g
s?[UuOo][Ll]>?\\end{itemize}?g
s?<[Mm][Ee][Nn][Uu]>?\\begin{itemize}?g
s?[Mm][Ee][Nn][Uu]>?\\end{itemize}?g
s?<[Ll][Ii]>?\\item ?g
#
# Glossary
s?<[Dd][Ll]>?\\begin{DL}{allow this much space}?g
s?[Dd][Ll]>?\\end{DL}?g
s?<[Dd][Tt]>?\\item[?g
s?<[Dd][Dd]>?]?g
#
# Anchors
# Avoid empty lines being craeted they will mess up TeX
/^<[Aa] [^>]*>$/d
/^<\/[Aa]>$/d
s?<[Aa]\n[^>]*>??g
s?<[Aa][^>]*>??g
s???g
#
# Up till now any < > were SGML < >. Now they must be real ones
s/$<$/g
s/>/$>$/g
# character set translations for SGML character refs and entities
# By this time the & have been escaped once.
s?\\&?\\\&?g
s?\\>?$>$?g
s?\\<?$<$?g
s?\\&\\#39;?\\\&?g
s?\\&\\#60;?$<$?g
s?\\&\\#62;?$>$?g
s?--?$--$?g
s?|?$|$?g
#
b done
###################################################################
# (jump here for preformatted text)
: pre
# TeX Macro paramter needs protection
# to be deleted: s?#?\\#?g
s?<[Pp][Rr][Ee]>?\\begin{verbatim}?g
s?[Pp][Rr][Ee]>?\\end{verbatim}?
# Anchors
s?<[Aa]\n[^>]*>??g
s?<[Aa][^>]*>??g
s???g
#
# character set translations for SGML character refs and entities
# By this time the & have been escaped once.
s?>?>?g
s?<??g
s?&\\#62;??\\begin{verbatim}?g
s?^[Xx][Mm][Pp]>?\\end{verbatim}?
s?^<[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>?\\begin{verbatim}?g
s?^[Ll][Ii][Ss][Tt][Ii][Nn][Gg]>?\\end{verbatim}?
###############################################################
: done
#
# Latex wrappers -- insert AFTER converstion to laTex!
#
# Put in a heading necessary for glossaries later, etc
# \\documentstyle[rfc]{cernman}\ (for rfc to be included)
#
1i\
\\documentstyle[rfc,times]{cernman}\
\\begin{document}
$a\
\\end{document}