% verbatim-mo testphase Module
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Highly experimental module for tagging characters in verbatim
% LaTeX Project March 2025
% Licence https://www.latex-project.org/lppl.txt
\ProvidesFile{verbatim-mo-latex-lab-testphase.ltx}
        [2025-03-31 v 0.1 Highly experimental module for tagging characters in verbatim]

\makeatletter
\begingroup \catcode `|=0 \catcode `[= 1
\catcode`]=2 \catcode `\{=13 \catcode `\}=13
\catcode`\\=12
|gdef|@xxverbatim#1\end{verbatim}[#1|end[verbatim]]
|gdef|@sxverbatim#1\end{verbatim*}[#1|end[verbatim*]]
|endgroup
\def\@xverbatim{\activechars\everypar{\tagobeyedline}\@xxverbatim}
\makeatother

\makeatother
\ExplSyntaxOn

\ExpandArgs{e}\tagpdfsetup{
  role/new-attribute=
    {intentnewline}
    {/O /NSO /NS~\pdf_object_ref:n {tag/NS/mathml}/intent /_newline}
  }
\ExplSyntaxOff
\def\defactive#1#2\relax{%
  \def#1{%
    \leavevmode\tagmcend\tagstructbegin{tag=Formula}\tagstructbegin{tag=math}\tagstructbegin{tag=mo}\tagmcbegin{}%
    \detokenize{#1}%
    \tagmcend\tagstructend\tagstructend\tagstructend\tagmcbegin{}}%
  }
\protected\gdef\tagobeyedline{%
    \tagmcend\tagstructbegin{tag=Formula}\tagstructbegin{tag=math}\tagstructbegin{tag=mrow,attribute=intentnewline}\tagmcbegin{}%
    \tagmcend\tagstructend\tagstructend\tagstructend\tagmcbegin{}}%

\begingroup
\catcode`\B=1
\catcode`\E=2
\catcode`\(\active
\catcode`\)\active
\catcode`\{\active
\catcode`\}\active
\catcode`\;\active
\catcode`\,\active
\catcode`\"\active

\gdef\activecharsB%
\catcode`\(\active
\catcode`\)\active
\catcode`\{\active
\catcode`\}\active
\catcode`\;\active
\catcode`\,\active
\catcode`\"\active
 \defactive(open paren\relax
 \defactive)close paren\relax
 \defactive{open brace\relax
 \defactive}close brace\relax
 \defactive;semicolon\relax
 \defactive,comma\relax
 \defactive"quote\relax
 E
\endgroup
