s/<i>/\\textit{/g;s/<b>/\\textbf{/g;s/<\/[ib]>/}/g;s/<url>/URL: \\textit\{/g;s/<\/url>/\}/g;
s/“/``/g;s/”/'"''"'/g;s/<lang:tex>//g;s/<\/lang:tex>//g;s/<lang:[^>]*>.*<\/lang:[^>]*>//g'
elif [ "$1" = "htm" ]; then
- sed "s/${NEWLI}${NEWLI}/<br>${NEWLI}/g;"'s/<url>\([^<]*\)<\/url>/<a href="\1">\1<\/a>/g;
-s/<lang:htm>//g;s/<\/lang:htm>//g;s/<lang:[^>]*>.*<\/lang:[^>]*>//g'
+ sed 's/<url>/\n<url>\n/g;s/<\/url>/\n<\/url>\n/g;
+ /^<url>$/,/^<\/url>$/ { s/\\_/_/g; };
+ /^<url>$/,/^<\/url>$/ { s/\(^[^<].*\)/<a href="\1">\1<\/a>/g; };
+ s/^<url>$//g;s/^<\/url>$//g' | tr -d '\n' | \
+ sed "s/${NEWLI}${NEWLI}/<br>${NEWLI}/g;"'
+ s/<lang:htm>//g;s/<\/lang:htm>//g;s/<lang:[^>]*>.*<\/lang:[^>]*>//g'
fi
)