# text (partly as html) to hyperref pdflatex conversion,
# a draft by jh, Feb 2007
sed -r '1i \
\\input a4_12l.ltx \
\\input mypdf.lt \
\\input myhtml.tex \
\\renewcommand{\\mylabel}[2]{\\protect\\label{#1}\\protect\\hypertarget{#1}{#2}} \
\\renewcommand {\\myref}[2]{\\protect\\hyperlink{#1}{#2}} \
\\begin{document}
/<[Hh]2>/h
s/<[Hh]2>/\\subsection*{/
/<[Hh]3>/h
s/<[Hh]3>/\\subsubsection*{/
/<\/[Hh][1234]>/{
s/<\/[Hh][1234]>/}/p
g
s/<[Hh]2>([^<]+)/\\addcontentsline{toc}{subsection}{\1}/
s/<[Hh]3>([^<]+)/\\addcontentsline{toc}{subsubsection}{\1}/
s/<\/[Hh][1234]>//
}
s/<[lL][iI]>/\\item{}/
s/<[oO][lL]>/\\begin{enumerate}/
s/<[oO][lL] start=([0-9]+)>/\\begin{enumerate}\\setcounter{enumi}{\1}/
s/<\/[oO][lL]>/\\end{enumerate}/
s/<[pP]>//
s/<[sS][uU][bB]>/\\ensuremath{_{/g
s/<\/[sS][uU][bB]>/}}/g
s/<[sS][uU][pP]>/\\ensuremath{^{/g
s/<\/[sS][uU][pP]>/}}/g
s/\ /~/g
s/\–/--/g
s/\×/\\mtimes{}/g
s/<[bB]>/\\textbf{/g
s/<\/[bB]>/}/g
s/<[eE][mM]>/\\emph{/g
s/<\/[eE][mM]>/}/g
s/<[iI]>/\\textit{/g
s/<\/[iI]>/}/g
s/<[aA] href="#([^"]+)">([^<]+)<\/A>/\\myref{\1}{\2}/
s/<[aA] name="([^"]+)">([^<]+)<\/A>/\\mylabel{\1}{\2}/
s/<[aA] href="#([^"]+)" name="([^"]+)">([^<]+)<\/A>/\\myref{\1}{\\mylabel{\2}{\3}}/
s/<[aA] name="([^"]+)" href="#([^"]+)">([^<]+)<\/A>/\\mylabel{\1}{\\myref{\2}{\3}}/
s/%/\\%/g
s/<[bB][rR]>/\\\\/g
s/<[aA] href="([^#][^"]+)">([^<]+)<\/A>/\\href{\1}{\2}/
s/<[hH][rR]>/\\hrulefill{}/
# ULRs at the end of the sentence (appended by .), inside a line
s|(http://[-a-zA-Z0-9/~_.]+[-a-zA-Z0-9/~_#]+)\.([ )])|\\wwws{\1}.\2|g
# ULRs at the end of the sentence (appended by .), ending a line
s|(http://[-a-zA-Z0-9/~_.]+[-a-zA-Z0-9/~_#]+)\.$|\\wwws{\1}.|g
# ULRs inside a sentence, inside a line
s|(http://[-a-zA-Z0-9/~_.#]+)([ ,);])|\\wwws{\1}\2|g
# ULRs inside a sentence, ending a line
s|(http://[-a-zA-Z0-9/~_.#]+)$|\\wwws{\1}|g
$a\
\\end{document}
' $1 > /tmp/bef_quo
sed -r "
s/\”/''/g
s/\“/``/g
" /tmp/bef_quo