%
% Here we determine the style of the syntax diagrams.
%
% Define a 'boxing' environment
\newenvironment{diagram}[2]%
{\begin{quote}\rule{0.5pt}{1ex}%
\rule[1ex]{\linewidth}{0.5pt}%
\rule{0.5pt}{1ex}\\[-0.5ex]%
\textbf{#1}\\[-0.5ex]}%
{\rule{0.5pt}{1ex}%
\rule{\linewidth}{0.5pt}%
\rule{0.5pt}{1ex}\end{quote}}
%\newenvironment{diagram}[2]{}{}
% Define mysyntdiag for my style of diagrams
\makeatletter
% Under Tex4HT, the diagrams are rendered as pictures.
\@ifpackageloaded{tex4ht}{%
\newenvironment{mysyntdiag}%
{\HCode{<BR/>}\Picture*{}\begin{syntdiag}\setlength{\sdmidskip}{.5em}\sffamily\sloppy}%
{\end{syntdiag}\EndPicture\HCode{<BR/>}}%
}{%
\newenvironment{mysyntdiag}%
{\begin{syntdiag}\setlength{\sdmidskip}{.5em}\sffamily\sloppy}%
{\end{syntdiag}}%
}% 
\makeatother
% Finally, define a combination of the above two.
\newenvironment{psyntax}[2]{\begin{diagram}{#1}{#2}\begin{mysyntdiag}}%
{\end{mysyntdiag}\end{diagram}}
% Redefine the styles used in the diagram.
\latex{\renewcommand{\litleft}{\bfseries\ }
\renewcommand{\ulitleft}{\bfseries\ }
\renewcommand{\syntleft}{\ }
\renewcommand{\litright}{\ \rule[.5ex]{.5em}{2\sdrulewidth}}
\renewcommand{\ulitright}{\ \rule[.5ex]{.5em}{2\sdrulewidth}}
\renewcommand{\syntright}{\ \rule[.5ex]{.5em}{2\sdrulewidth}}
}
% Finally, a referencing command.
\newcommand{\seesy}[1]{see diagram}
%