Support for bidirectional typesetting in plain TeX and LaTeX