| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: latex-lab-text.dtx (C) Copyright 2023-2025 LaTeX Project |
| 4 |
% |
| 5 |
% It may be distributed and/or modified under the conditions of the |
| 6 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 7 |
% license or (at your option) any later version. The latest version |
| 8 |
% of this license is in the file |
| 9 |
% |
| 10 |
% https://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% |
| 13 |
% The development version of the bundle can be found below |
| 14 |
% |
| 15 |
% https://github.com/latex3/latex2e/required/latex-lab |
| 16 |
% |
| 17 |
% for those people who are interested or want to report an issue. |
| 18 |
% |
| 19 |
\def\ltlabtextdate{2025-05-10} |
| 20 |
\def\ltlabtextversion{0.85f} |
| 21 |
|
| 22 |
%<*driver> |
| 23 |
\DocumentMetadata{tagging=on,pdfstandard=ua-2} |
| 24 |
\documentclass[kernel]{l3doc} |
| 25 |
\usepackage{latex-lab-testphase-l3doc} |
| 26 |
% for the phoneme argument |
| 27 |
\usepackage{fontspec} |
| 28 |
\setmonofont{NewCMMono10-Book.otf} |
| 29 |
|
| 30 |
%\DeclareUnicodeCharacter{02C8}{\texttt{\textquotesingle}} |
| 31 |
%\DeclareUnicodeCharacter{02D0}{\texttt{:}} |
| 32 |
%\DeclareUnicodeCharacter{025B}{$\epsilon$} |
| 33 |
|
| 34 |
\EnableCrossrefs |
| 35 |
\CodelineIndex |
| 36 |
\begin{document} |
| 37 |
\DocInput{latex-lab-text.dtx} |
| 38 |
\end{document} |
| 39 |
%</driver> |
| 40 |
% |
| 41 |
% \fi |
| 42 |
% |
| 43 |
% \title{The \textsf{latex-lab-text} package\\ |
| 44 |
% Changes and additions to the kernel related to the tagging of various small text commands} |
| 45 |
% \author{\LaTeX{} Project\thanks{Initial implementation done by Ulrike Fischer}} |
| 46 |
% \date{v\ltlabtextversion\ \ltlabtextdate} |
| 47 |
% |
| 48 |
% \maketitle |
| 49 |
% |
| 50 |
% \newcommand{\xt}[1]{\textsl{\textsf{#1}}} |
| 51 |
% \newcommand{\TODO}[1]{\textbf{[TODO:} #1\textbf{]}} |
| 52 |
% \newcommand{\docclass}{document class \marginpar{\raggedright document class |
| 53 |
% customizations}} |
| 54 |
% |
| 55 |
% \providecommand\hook[1]{\texttt{#1}} |
| 56 |
% |
| 57 |
% \begin{abstract} |
| 58 |
% \end{abstract} |
| 59 |
% |
| 60 |
% \section{Introduction} |
| 61 |
% |
| 62 |
% The followings contains small changes to improve the tagging of |
| 63 |
% (inline) text commands. |
| 64 |
% |
| 65 |
% While the tagging of the \LaTeX{} logo is quite straightforward, tagging of |
| 66 |
% \cs{emph} as \texttt{EM} and \cs{textbf} as \texttt{Strong} |
| 67 |
% can have unwanted side-effect as both tags are inline tags and so not every inner |
| 68 |
% structure is allowed. Probably both commands will need an optional argument or a |
| 69 |
% starred variant which suppress the tagging. |
| 70 |
% |
| 71 |
% \section{Implementation} |
| 72 |
% \begin{macrocode} |
| 73 |
%<*package> |
| 74 |
%<@@=tag> |
| 75 |
% \end{macrocode} |
| 76 |
% \begin{macrocode} |
| 77 |
\ProvidesExplPackage {latex-lab-testphase-text} {\ltlabtextdate} {\ltlabtextversion} |
| 78 |
{Code related to the tagging of various small text commands} |
| 79 |
% \end{macrocode} |
| 80 |
|
| 81 |
% \subsection{The \LaTeX\ and \TeX\ logo} |
| 82 |
% This uses the generic hooks, so that it catches also other definitions. |
| 83 |
% For \cs{LaTeX} we stop tagging to avoid that the inner \cs{TeX} leads to a double tagging. |
| 84 |
% \begin{macrocode} |
| 85 |
\AddToHook{cmd/LaTeX/before} |
| 86 |
{ |
| 87 |
\mode_leave_vertical: |
| 88 |
\tag_mc_end_push: |
| 89 |
\tag_struct_begin:n{tag=Span,actualtext=LaTeX,phoneme=[ˈlaːtɛx]} |
| 90 |
\tag_mc_begin:n{} |
| 91 |
\tag_suspend:n{LaTeX} |
| 92 |
} |
| 93 |
\AddToHook{cmd/LaTeX/after} |
| 94 |
{ |
| 95 |
\tag_resume:n{LaTeX} |
| 96 |
\tag_mc_end: |
| 97 |
\tag_struct_end: |
| 98 |
\tag_mc_begin_pop:n{} |
| 99 |
} |
| 100 |
\AddToHook{cmd/TeX/before} |
| 101 |
{ |
| 102 |
\mode_leave_vertical: |
| 103 |
\tag_mc_end_push: |
| 104 |
\tag_struct_begin:n{tag=Span,actualtext=TeX} |
| 105 |
\tag_mc_begin:n{} |
| 106 |
} |
| 107 |
\AddToHook{cmd/TeX/after} |
| 108 |
{ |
| 109 |
\tag_mc_end: |
| 110 |
\tag_struct_end: |
| 111 |
\tag_mc_begin_pop:n{} |
| 112 |
} |
| 113 |
% \end{macrocode} |
| 114 |
% |
| 115 |
% \subsection{Emphasizing} |
| 116 |
% We tag \cs{emph} but leave commands like \cs{textbf} alone, as it is not |
| 117 |
% clear if they always have a semantic meaning. |
| 118 |
% \begin{macrocode} |
| 119 |
\AddToHook{cmd/emph/before} |
| 120 |
{ |
| 121 |
\mode_leave_vertical: |
| 122 |
\tag_mc_end_push: |
| 123 |
\tag_struct_begin:n{tag=Em} |
| 124 |
\tag_mc_begin:n{} |
| 125 |
} |
| 126 |
|
| 127 |
\AddToHook{cmd/emph/after} |
| 128 |
{ |
| 129 |
\tag_mc_end: |
| 130 |
\tag_struct_end: |
| 131 |
\tag_mc_begin_pop:n{} |
| 132 |
} |
| 133 |
% \end{macrocode} |
| 134 |
% |
| 135 |
% \subsection{cs{mbox}} |
| 136 |
% When used in math and when luamml is active \cs{mbox} has to be correctly annoted. |
| 137 |
% For this we add a socket that luamml can activate. |
| 138 |
% We test for the socket until 2025-06-01. |
| 139 |
% \changes{v0.85c}{2024-12-03}{Add luamml socket to \cs{mbox}} |
| 140 |
% \begin{macrocode} |
| 141 |
\DeclareRobustCommand\mbox[1] |
| 142 |
{ |
| 143 |
\leavevmode |
| 144 |
\tag_socket_use:nnn {math/luamml/hbox} |
| 145 |
{}{ \hbox{#1} } |
| 146 |
} |
| 147 |
% \end{macrocode} |
| 148 |
% And the same for \cs{makebox} |
| 149 |
% \begin{macrocode} |
| 150 |
\long\def\@imakebox[#1][#2]#3{% |
| 151 |
\tag_socket_use:nnn {math/luamml/hbox}{} |
| 152 |
{ |
| 153 |
\@begin@tempboxa\hbox{#3}% |
| 154 |
\setlength\@tempdima{#1}% support calc |
| 155 |
\hb@xt@\@tempdima{% |
| 156 |
\expandafter\ifx\csname bm@#2\endcsname\relax |
| 157 |
\bm@c |
| 158 |
\@latex@warning{Unexpected~alignment~#2}% |
| 159 |
\else |
| 160 |
\csname bm@#2\endcsname |
| 161 |
\fi}% |
| 162 |
\@end@tempboxa |
| 163 |
}} |
| 164 |
% \end{macrocode} |
| 165 |
% |
| 166 |
% \subsection{phantom commands} |
| 167 |
% |
| 168 |
% In text mode we do not want the content of a phantom command to create a structure, |
| 169 |
% so we suspend tagging |
| 170 |
% \changes{0.85d}{2025-01-27}{Suspend tagging in \cs{makeph@nt}} |
| 171 |
% TODO: consider if it makes sense to set measuring to true instead. |
| 172 |
% \cs{mathsm@sh} is redefined in latex-lab-math. |
| 173 |
% \begin{macro}[no-user-doc]{\makeph@nt} |
| 174 |
% \begin{macrocode} |
| 175 |
\def\makeph@nt#1{% |
| 176 |
\setbox\z@\hbox |
| 177 |
{\SuspendTagging{\makeph@nt}% |
| 178 |
\color@begingroup#1\color@endgroup\ResumeTagging{\makeph@nt}}\finph@nt} |
| 179 |
% \end{macrocode} |
| 180 |
% \end{macro} |
| 181 |
% |
| 182 |
% |
| 183 |
% \begin{macro}[no-user-doc]{\@kernel@mathph@nt,\mathph@nt} |
| 184 |
% \begin{macrocode} |
| 185 |
\def\@kernel@mathph@nt#1#2{% |
| 186 |
\setbox\z@\hbox{\SuspendTagging{\mathph@nt}$\m@th#1{#2}$\ResumeTagging{\mathph@nt}}\finph@nt} |
| 187 |
\def\mathph@nt#1#2 |
| 188 |
{ |
| 189 |
\setbox \z@ = \hbox { |
| 190 |
$ |
| 191 |
\m@th |
| 192 |
#1 |
| 193 |
{ |
| 194 |
% nested phantoms should not be processed by luamml |
| 195 |
\let\mathph@nt\@kernel@mathph@nt |
| 196 |
#2 |
| 197 |
} |
| 198 |
\UseTaggingSocket{math/luamml/save/nNn}{{mathphant} #1 {mphantom}} |
| 199 |
$ |
| 200 |
} |
| 201 |
\UseTaggingSocket{math/luamml/finph@nt}{}{\finph@nt} |
| 202 |
} |
| 203 |
% \end{macrocode} |
| 204 |
% \end{macro} |
| 205 |
% \begin{macrocode} |
| 206 |
%</package> |
| 207 |
% \end{macrocode} |
| 208 |
% \begin{macrocode} |
| 209 |
%<*latex-lab> |
| 210 |
\ProvidesFile{text-latex-lab-testphase.ltx} |
| 211 |
[\ltlabtextdate\space v\ltlabtextversion\space |
| 212 |
code related to the tagging of various small text commands] |
| 213 |
|
| 214 |
\RequirePackage{latex-lab-testphase-text} |
| 215 |
|
| 216 |
%</latex-lab> |
| 217 |
% \end{macrocode} |