# escape '&', '{', '}', '#', '_' with preceding '\'.
# however, leave '&#' as is.
sed -e 's|[$]|\\$|g'  -e 's|[{]|\\{|g' -e 's|[}]|\\}|g' \
    -e 's|\([^&]\)#|\1\\#|g'  -e 's|%|\\%|g'  -e 's|_|\\_|g' \
| xsltproc --stringparam output latex "$@" - \
| sed -e ':LOOP' \
      -e '/begin{alltt}/N' \
      -e '/begin{alltt}.*end{alltt}/bDONE' \
      -e '/begin{alltt}.*/s/$/\\\\/g' \
      -e 'tLOOP' \
      -e ':DONE' \
      -e '/begin{alltt}/s/ /\\verb| |/g' \
      -e '/begin{alltt}/s/\\\\\n\\end{alltt}/}\\par/' \
      -e 's/\\begin{alltt}/\\par{\\tt/' \
| sed -e 's|​|\\discretionary{}{}{}|g'
