% \iffalse meta-comment
%
%% File: latex-lab-text.dtx (C) Copyright 2023-2024 LaTeX Project
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file
%
%    https://www.latex-project.org/lppl.txt
%
%
% The development version of the bundle can be found below
%
%    https://github.com/latex3/latex2e/required/latex-lab
%
% for those people who are interested or want to report an issue.
%
\def\ltlabtextdate{2023-07-20}
\def\ltlabtextversion{0.85a}

%<*driver>
\documentclass{l3doc}
\EnableCrossrefs
\CodelineIndex
\begin{document}
  \DocInput{latex-lab-text.dtx}
\end{document}
%</driver>
%
% \fi
%
% \title{The \textsf{latex-lab-text} package\\
% Changes and additions to the kernel related to the tagging of various small text commands}
% \author{\LaTeX{} Project\thanks{Initial implementation done by Ulrike Fischer}}
% \date{v\ltlabtextversion\ \ltlabtextdate}
%
% \maketitle
%
% \newcommand{\xt}[1]{\textsl{\textsf{#1}}}
% \newcommand{\TODO}[1]{\textbf{[TODO:} #1\textbf{]}}
% \newcommand{\docclass}{document class \marginpar{\raggedright document class
% customizations}}
%
% \providecommand\hook[1]{\texttt{#1}}
%
% \begin{abstract}
% \end{abstract}
%
% \section{Introduction}
%
% The followings contains small changes to improve the tagging of
% (inline) text commands.
% 
% While the tagging of the \LaTeX{} logo is quite straightforward, tagging of
% \cs{emph} as \texttt{EM} and \cs{textbf} as \texttt{Strong}
% can have unwanted side-effect as both tags are inline tags and so not every inner
% structure is allowed. Probably both commands will need an optional argument or a
% starred variant which suppress the tagging.
% 
% \section{Implementation}
%    \begin{macrocode}
%<*package>
%<@@=tag>
%    \end{macrocode}
%    \begin{macrocode}
\ProvidesExplPackage {latex-lab-testphase-text} {\ltlabtextdate} {\ltlabtextversion}
  {Code related to the tagging of various small text commands}
%    \end{macrocode}

% \subsection{The \LaTeX\ and \TeX\ logo}
% This uses the generic hooks, so that it catches also other definitions.
% For \cs{LaTeX} we stop tagging to avoid that the inner \cs{TeX} leads to a double tagging.
%    \begin{macrocode}
\AddToHook{cmd/LaTeX/before}
  {
    \mode_leave_vertical:
    \tag_mc_end_push:
    \tag_struct_begin:n{tag=Span,actualtext=LaTeX}
    \tag_mc_begin:n{}
    \tag_stop:n{LaTeX}
  }
\AddToHook{cmd/LaTeX/after}
 { 
   \tag_start:n{LaTeX}
   \tag_mc_end:
   \tag_struct_end:
   \tag_mc_begin_pop:n{}
 }
\AddToHook{cmd/TeX/before}
 {
   \mode_leave_vertical:
   \tag_mc_end_push:
   \tag_struct_begin:n{tag=Span,actualtext=TeX}
   \tag_mc_begin:n{}
 }
\AddToHook{cmd/TeX/after}
 {
   \tag_mc_end:
   \tag_struct_end:
   \tag_mc_begin_pop:n{}
 }
%    \end{macrocode}
%
% \subsection{Emphasizing} 
% We tag \cs{emph} but leave commands like \cs{textbf} alone, as it is not
% clear if they always have a semantic meaning.
%    \begin{macrocode}
\AddToHook{cmd/emph/before}
  {
    \mode_leave_vertical:
    \tag_mc_end_push:
    \tag_struct_begin:n{tag=Em}
    \tag_mc_begin:n{}
  }

\AddToHook{cmd/emph/after}
  {
    \tag_mc_end:
    \tag_struct_end:
    \tag_mc_begin_pop:n{}
  }
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%    \begin{macrocode}
%<*latex-lab>
\ProvidesFile{text-latex-lab-testphase.ltx}
        [\ltlabtextdate\space v\ltlabtextversion\space
         code related to the tagging of various small text commands]

\RequirePackage{latex-lab-testphase-text}

%</latex-lab>
%    \end{macrocode}
