H !# Include proxy title !# Insert fallback values ??a . w !# Include the template files via script g/\(/s//\1/ g//s//\1/ g//d g//d g//d g//d !# Mark all the lines with end-of-line separator g/$/s//|||/ !# Var substitution: Duplicate var defintion !# to before all the var-containing lines 10,$g/SELF/??t. 10,$g/SUBTITLE/??t. 10,$g/[^B]TITLE/??t. 10,$g/DESCRIPTION/?<DESCRIPTION>?t. 10,$g/IMAGE[^_]/?<IMAGE>?t. 10,$g/IMAGE_ALT/?<IMAGE_ALT>?t. !# No need for colors here !# Substitute all vars into the text 10,$g/<\([A-Z_]*\)>.*<\/\1>/-1,.j\ s/\([A-Z_]*\)\(.*\)||| *<\1>\([^|]*\)<\/\1>|||/\3\2|||/ !# Split lines (no longer necessary) g/|||$/s/// g/|||/s//\ /g !# Remove all the var definitions /<head>/,/<\/head/g/<\(SELF\)*\(SUBTITLE\)*\(DESCRIPTION\)*\(IMAGE\)*\(_ALT\)*>/d g/^ *[<#]include/d !# Remove all of the head /<head>/,/<\/head>/d !# Replace all kinds of char macros g/HASH()/s//#/g g/SQUOTE()/s//'/g g/DQUOTE()/s//"/g g/LT()/s//</g g/GT()/s//>/g g/AMP()/s//\&/g g/NUM()/s//#/g g/#/s//#/g g/'/s//'/g g/"/s//"/g g/</s//</g g/>/s//>/g g/&/s//\&/g g/%/s//%/g !# Trivial non-text macros g/HYPERTEXTONLY(.*)/d g/GEMTEXTONLY(.*)/d g/LATEXONLY(.*)/d g/MANONLY(.*)/d g/EXCEPTHYPERTEXT(\(.*\))/s//\1/ g/EXCEPTGEMTEXT(\(.*\))/s//\1/ g/EXCEPTLATEX(\(.*\))/s//\1/ g/EXCEPTMAN(\(.*\))/s//\1/ g/END(DETAILS)/s//)/ g/END(.*)/d g/^<p[ >]/d g/^P(.*)/d g/FIG()/d g/INPUT(.*)/d !# Links g/A(\([^ ]*\), *\([^)]*\(([^)]*)\)*[^)]*)*\))/s//\2 <\1>/ g/AID(\([^ ]*\), *\([^ ]*\), \([^)]*\(([^)]*)\)*[^)]*)*\))/s//\3 <\1#\2>/ g/AHERE(\([^ ]*\), *\([^)]*\(([^)]*)\)*[^)]*)*\))/s//\2 <\1.txt>/ g/<a \([^:>=]*\)\.htm>\(.*\)<\/a>/s//\2 <\1.txt>/g g/<a \([^:>=]*\)\.htm#\([^:>=]*\)>\(.*\)<\/a>/s//\3 <\1.txt, section \2>/g g/<a href=\(.*\)>\(.*\)<\/a>/s//\2 <\1>/g g/<a \(...[^:=][^:=][^:=][^:=][^>]*\)>\(.*\)<\/a>/s//\2 <\1>/g !# Media g/<img.*src=\([^ ]*\).*alt=['"]\(.*\)['"]>/s//<\1> (\2)/ g/<img.*src=\([^ ]*\).*alt=\(.*\)>/s//<\1> (\2)/ g/<img \([^ ]*\) \(\([^"' ]* \)\{5,\}.*\)>/s//<\1> (\2)/ g/IMG(\([^ ]*\), *\(.*\))/s//<\1> (\2)/ g/PIC(\([^ ]*\), *\([^ ]*\), \(.*\))/s//<\1> (\3)/ g/AUDIO(\([^ ]*\), *\(.*\))/s//<\1>/ g/VIDEO(\([^ ]*\), *\(.*\))/s//<\1>/ !# Blocks g/FIGCAP(\(.*\))/s//-- \1/ g/<\/figure \(.*\)>/s//-- \1/\ ?<figure?d g/<\/pre /s/<\/pre \(.*\)>/==================== \1 ====================/\ ?^<pre \(.*\)>?s//=================================== \1 ===================================/ g/PRE(\(.*\))/s//=================================== \1 ===================================/ g/PRECAP(\(.*\))/s//==================== \1 ====================/ g/BQ()/s//> / g/BQCAP(\(.*\))/s//-- \1/ g/^<\/q \(.*\)>/?<q *\(.*\)>?,-1s/$/ /\ ?<q *\(.*\)>?,.j\ s/<q *\(.*\)> */> /\ s/ *$//\ +1s/<\/q *\(.*\)>/-- \1/ !# Lists g/^ *D[DL](\(.*\))/s//\1:/g g/^ *[UO]*LI */s//- /g g/^ *[UO]L(\([^)]*\)) */s//- /g g/^ *<[uo]l\([^>]*\)> *\(.\{1,\}\)/s//- \2/ g/^ *<dl\([^>]*\)> *\(.\{1,\}\)/s//\2:/ g/^ *<dt> *\(.*\)/s//\1:/ g/^ *<dd> */s/// g/^ *<li> */s//- / g/<\/[uod]l>/d !# Minor markup g/CD(\([^)]*\(([^)]*)\)*[^)]*\))/s//`\1`/g g/VAR(\([^)]*\(([^)]*)\)*[^)]*\))/s//`\1`/g g/KBD(\([^)]*\(([^)]*)\)*[^)]*\))/s//<\1>/g g/EM(\([^)]*\(([^)]*)\)*[^)]*\))/s//*\1*/g g/<cd \([^>]*\)>/s//`\1`/g g/<e \([^>]*\)>/s//*\1*/g !# New tab-separated tables g/<table.* .*>/s/<table[[:space:]]*\(.*\)>$/<table >\ \1/ g/<table.* /.+1,/<\/table/-1s/^[[:space:]]*//g g/<table.* /.+1,/<\/table/-1s/ / |/g g/<table.* /.+1,/<\/table/-1s/$/ |/g g/<table.* /.+1,/<\/table/-1s/^/|/g g/<table.* >/d g/<\/table \(.*\)>/s//-- \1/ !# Tables g/T[DH](\([^)]*\))/s//\1 |/ g/T[AR][OB](\(.*\))/s//|\1 |/ g/T[AR][OB]2(\([^,]*\), *\(.*\))/s//|\1 |\2 |/ g/T[AR][OB]3(\([^,]*\), *\([^,]*\), *\(.*\))/s//|\1 |\2 |\3 |/ g/T[AR][OB]4(\([^,]*\), *\([^,]*\), *\([^,]*\), *\(.*\))/s//|\1 |\2 |\3 |\4 |/ g/T[AR][OB]5(\([^,]*\), *\([^,]*\), *\([^,]*\), *\([^,]*\), *\(.*\))/s//|\1 |\2 |\3 |\4 |\5 |/ g/TABCAP(\(.*\))/s//-- \1/ !# Sections g/SECTION2(\([^,]*\), *\(.*\))/s//## \2 (#\1)/ g/SECTION3(\([^,]*\), *\(.*\))/s//### \2 (#\1)/ g/SECTION4(\([^,]*\), *\(.*\))/s//#### \2 (#\1)/ g/SECTION5(\([^,]*\), *\(.*\))/s//##### \2 (#\1)/ g/SECTION6(\([^,]*\), *\(.*\))/s//###### \2 (#\1) g/<h2 \([^ =>]*\)> *\(.*\)<\/h2>/s//## \2 (#\1)/ g/<h3 \([^ =>]*\)> *\(.*\)<\/h3>/s//### \2 (#\1)/ g/<h4 \([^ =>]*\)> *\(.*\)<\/h4>/s//#### \2 (#\1)/ g/<h5 \([^ =>]*\)> *\(.*\)<\/h5>/s//##### \2 (#\1)/ g/<h6 \([^ =>]*\)> *\(.*\)<\/h6>/s//###### \2 (#\1)/ g/<details \([^>]*\)>/s//(\1:/ g/<\/details>/s//)/ g/DETAILS(\(.*\))/s//(\1:/ g/<hr>/s//HR()/ g/HR()/s//================================================================================/ w Q