summaryrefslogtreecommitdiff
path: root/macros/latex/required/latex-lab/latex-lab-text.dtx
blob: fe9b6ababc73de75cf14e34e5de3d017f77ec7e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
% \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}