Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagging issues 777 and 778 #1607

Merged
merged 14 commits into from
Jan 16, 2025
5 changes: 5 additions & 0 deletions required/latex-lab/changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2025-01-05 Ulrike Fischer <[email protected]>
* latex-lab-sec.dtx: add \par before \mainmatter etc (tagging/777)
* latex-lab-table.dtx: use ARIA-role as default for presentation tables (tagging/778), add option to use Div-structures instead of Table.


2024-12-27 Frank Mittelbach <[email protected]>

* latex-lab-table.dtx,latex-lab-toc-kernel-changes.dtx,
Expand Down
13 changes: 7 additions & 6 deletions required/latex-lab/latex-lab-sec.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
%
% for those people who are interested or want to report an issue.
%
\def\ltlabsecdate{2024-10-04}
\def\ltlabsecversion{0.84f}
\def\ltlabsecdate{2025-01-05}
\def\ltlabsecversion{0.84g}
%<*driver>
\documentclass[kernel]{l3doc}
\EnableCrossrefs
Expand Down Expand Up @@ -359,11 +359,12 @@
%
% The commands \cs{mainmatter}, \cs{backmatter}, \cs{frontmatter} and
% \cs{appendix} close all \texttt{Sect} and \texttt{Part} structures.
% \changes{v0.84g}{2025/01/05}{ensure that paragraph is ended (tagging/777)}
% \begin{macrocode}
\AddToHook{cmd/frontmatter/before}{\@@_sec_end:n{-10}}
\AddToHook{cmd/mainmatter/before} {\@@_sec_end:n{-10}}
\AddToHook{cmd/backmatter/before} {\@@_sec_end:n{-10}}
\AddToHook{cmd/appendix/before} {\@@_sec_end:n{-10}}
\AddToHook{cmd/frontmatter/before}{\par\@@_sec_end:n{-10}}
\AddToHook{cmd/mainmatter/before} {\par\@@_sec_end:n{-10}}
\AddToHook{cmd/backmatter/before} {\par\@@_sec_end:n{-10}}
\AddToHook{cmd/appendix/before} {\par\@@_sec_end:n{-10}}
Comment on lines +364 to +367
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better would be to move the \par command into those comands eventually (to ensure that they always behave identically (with or without tagging).

Also (not checked) but isn't \@@_sec_end:n{-10} a related command and should be in a socket rather than a hook?

Doesn't have to be done now, but there should be a TODO if this is something we should cleanup at some point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if a \par inside \@@_sec_end:n is always wanted that's why I added if here explicitly (In the other cases the command is currently is used inside the sectioning commands in vmode, so a \par inside the command is not needed).

I'm not sure what you mean by sockets. \mainmatter etc are defined by the classes, so we can not simply redefine them to add a socket but have to use a generic hook. The problem was that the hook is before the \clearpage and so not necessarly in vmode.

% \end{macrocode}
%
% \subsection{Tagging tools}
Expand Down
115 changes: 93 additions & 22 deletions required/latex-lab/latex-lab-table.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
%
% for those people who are interested or want to report an issue.
%
\def\ltlabtbldate{2024-12-27}
\def\ltlabtblversion{0.85o}
\def\ltlabtbldate{2025-01-05}
\def\ltlabtblversion{0.85p}
%<*driver>
\documentclass{l3doc}
\EnableCrossrefs
Expand Down Expand Up @@ -138,17 +138,24 @@
% as a layout to ensure that the content is properly aligned
% or because it is a not yet (fully) supported table structure,
% the tagging can be disabled with
% \verb|\tagpdfsetup{table/tagging=false}| or with \verb|\tagpdfsetup{table/tagging=presentation}|%
% \verb|\tagpdfsetup{table/tagging=false}| or changed with
% \verb|\tagpdfsetup{table/tagging=presentation}| or \verb|\tagpdfsetup{table/tagging=div}|%
% \footnote{The key has been renamed. The old name `table-tagging` still works but is
% deprecated. The value \texttt{presentation} refers to the ARIA role \enquote{presentation}.}
% The first option disables the table tagging code and the content of the tabular
% is then treated more or less like running text. This works ok for simple tables using
% only hmode-cells (l/c/r) with normal text content, but fails if the table uses vmode-cells
% (p/m/b). In such cases the second option works better: it keeps the tagging code active
% but changes the tag names to \texttt{Div} and the grouping structure \texttt{NonStruct}. It also
% (re)sets the \texttt{table/header-rows} key to empty.
% The key should currently only be used in a group as there is no key (yet) to reset to the default
% tag names.
% (p/m/b). In such cases the second option works better: it keeps the tagging code active,
% but adds an ARIA-role as attribute to indicate that this is a presentation table.
% When deriving to html this gives the best result
% as it keeps the layout.
% The last option changes the tag names and creates simply a number of DIV structures.
% Both options also
% (re)set the \texttt{table/header-rows} and \texttt{table/header-columns} keys to empty.
%
% To reset to the normal tagging in the current group (e.g. inside a presentation
% table) one can use \verb|\tagpdfsetup{table/tagging=true}| (and if needed reenable the headers).
%
%
% \subsection{Header rows and columns}
% There is some basic support\footnote{This is not meant to be the
Expand Down Expand Up @@ -228,7 +235,8 @@
% \item Not every table should be tagged as a Table structure, often they are
% only used as layout help, e.g. to align authors in a title pages. In such uses
% the tagging of the table must be deactivated with \verb|\tagpdfsetup{table/tagging=false}|
% or \verb|\tagpdfsetup{table/tagging=presentation}|.
% or changed with \verb|\tagpdfsetup{table/tagging=presentation}| or
% \verb|\tagpdfsetup{table/tagging=div}|.
%
% \item Only simple header rows and columns are currently supported. Complex headers with
% subheaders will be handled later as that needs some syntax changes. Tables
Expand Down Expand Up @@ -827,9 +835,6 @@
% \end{macrocode}
% \end{plugdecl}
%
%
%
%
% \begin{plugdecl}{Table}
% \begin{macrocode}
\NewSocketPlug{tagsupport/tbl/hmode/begin}{Table}
Expand All @@ -847,6 +852,26 @@
}
% \end{macrocode}
% \end{plugdecl}
%
% \begin{plugdecl}{LayoutTable}
% \changes{v0.85p}{2025/01/05}{new plugs for layout tables (tagging/778)}
% This plug is meant for presentation tables, it sets the ARIA role.
% \begin{macrocode}
\NewSocketPlug{tagsupport/tbl/hmode/begin}{LayoutTable}
{
\tag_mc_end_push:
% \end{macrocode}
% Close the P-chunk. This assumes that para-tagging is active.
% For nested tables that is not necessarily true, so we test for it.
% \begin{macrocode}
\bool_lazy_and:nnT
{ \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool }
{ \tag_struct_end:n { text } }
\tag_struct_begin:n {tag=\l_@@_tabletag_tl,attribute-class=ARIA-role-presentation}
\tl_gset:Ne \g_@@_struct_table_tl { \tag_get:n {struct_num} }
}
% \end{macrocode}
% \end{plugdecl}
%
% \begin{plugdecl}{Table}
% \begin{macrocode}
Expand Down Expand Up @@ -874,6 +899,17 @@
}
% \end{macrocode}
% \end{plugdecl}
%
% \begin{plugdecl}{Table}
% \begin{macrocode}
\NewSocketPlug{tagsupport/tbl/vmode/begin}{LayoutTable}
{
\tag_struct_begin:n {tag=\l_@@_tabletag_tl,attribute-class=ARIA-role-presentation}
\tl_gset:Ne \g_@@_struct_table_tl { \tag_get:n {struct_num} }
}
% \end{macrocode}
% \end{plugdecl}
%
%
% \begin{plugdecl}{Table}
% \begin{macrocode}
Expand Down Expand Up @@ -1015,26 +1051,58 @@
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_init_tagnames_default:,\@@_init_tagnames_div:}
% These commands are used to switch the tagnames.
% \begin{macrocode}
\cs_new_protected:Npn\@@_init_tagnames_default:
{
\tl_set:Nn\l_@@_rowtag_tl {TR}
\tl_set:Nn\l_@@_pcelltag_tl {TD}
\tl_set:Nn\l_@@_celltag_tl {TD}
\tl_set:Nn\l_@@_tabletag_tl {Table}
}

\cs_new_protected:Npn\@@_init_tagnames_div:
{
\tl_set:Nn\l_@@_rowtag_tl {NonStruct}
\tl_set:Nn\l_@@_pcelltag_tl {NonStruct}
\tl_set:Nn\l_@@_celltag_tl {text}
\tl_set:Nn\l_@@_tabletag_tl {Div}
}
% \end{macrocode}
% \end{macro}

% \begin{macrocode}
% See tagpdfsetup-keys.md in tagpdf/doc for the naming scheme.
\keys_define:nn { __tag / setup }
{
table/tagging .choices:nn = { true, on }
{ \__tag_tbl_enable: },
{
\__tag_tbl_enable:
\@@_init_tagnames_default:
},
table/tagging .choices:nn = { false, off }
{ \__tag_tbl_disable: },
table/tagging .choice:,
table/tagging / presentation .code:n =
{
\__tag_tbl_enable:
\tl_set:Nn\l_@@_rowtag_tl {NonStruct}
\tl_set:Nn\l_@@_pcelltag_tl {NonStruct}
\tl_set:Nn\l_@@_celltag_tl {text}
\tl_set:Nn\l_@@_tabletag_tl {Div}
\clist_clear:N \l_@@_header_rows_clist
\clist_clear:N \l_@@_header_columns_clist
},
{
\__tag_tbl_enable:
\@@_init_tagnames_default:
\AssignSocketPlug{tagsupport/tbl/hmode/begin}{LayoutTable}
\AssignSocketPlug{tagsupport/tbl/vmode/begin}{LayoutTable}
\clist_clear:N \l_@@_header_rows_clist
\clist_clear:N \l_@@_header_columns_clist
},
table/tagging / div .code:n =
{
\__tag_tbl_enable:
\@@_init_tagnames_div:
\AssignSocketPlug{tagsupport/tbl/hmode/begin}{LayoutTable}
\AssignSocketPlug{tagsupport/tbl/vmode/begin}{LayoutTable}
\clist_clear:N \l_@@_header_rows_clist
\clist_clear:N \l_@@_header_columns_clist
},
table/tagging .default:n = true,
table/tagging .initial:n = true
}
Expand Down Expand Up @@ -1071,6 +1139,7 @@
% At first we define attributes for the three standard cases:
% We delay to begin document
% as we can't know if tagpdf is already loaded.
% \changes{v0.85p}{2025/01/05}{add ARIA-role for presentation (tagging/778)}
% \begin{macrocode}
\AddToHook{begindocument}
{
Expand All @@ -1084,6 +1153,8 @@
{TH-row}{/O /Table /Scope /Row},
role/new-attribute =
{TH-both}{/O /Table /Scope /Both},
role/new-attribute =
{ARIA-role-presentation}{/O /ARIA-1.1/role (presentation)}
}
% \end{macrocode}
%
Expand Down
33 changes: 33 additions & 0 deletions required/latex-lab/testfiles-sec/test-gh777-sec-end.luatex.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
Chapter 1.
[1
]
[2
]
[1
Non-PDF special ignored!]
[2
]
Chapter 2.
[1
]
[2
]
[3
Non-PDF special ignored!]
[4
]
[5
Non-PDF special ignored!] (test-gh777-sec-end.aux)
Package tagpdf Info: Finalizing the tagging structure:
(tagpdf) Writing out ~38 structure objects
(tagpdf) with ~30 'MC' leaf nodes.
(tagpdf) Be patient if there are lots of objects!
Package tagpdf Info: writing ParentTree
Package tagpdf Info: writing IDTree
Package tagpdf Info: writing RoleMap
Package tagpdf Info: writing ClassMap
Package tagpdf Info: writing NameSpaces
Package tagpdf Info: writing StructElems
Package tagpdf Info: writing Root
27 changes: 27 additions & 0 deletions required/latex-lab/testfiles-sec/test-gh777-sec-end.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
\DocumentMetadata
{
lang=en-US,
pdfversion=2.0,
pdfstandard=ua-2,
testphase={latest},
}
\input{regression-test}
\documentclass{book}

\begin{document}
\START
\chapter{abc}
blub
\frontmatter
\chapter{abc}
blub
\mainmatter
\chapter{main}
blub
\backmatter
\chapter{main}
blub
\appendix
\chapter{main}
blub
\end{document}
32 changes: 32 additions & 0 deletions required/latex-lab/testfiles-sec/test-gh777-sec-end.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
Chapter 1.
[1
]
[2
]
[1
]
[2
]
Chapter 2.
[1
]
[2
]
[3
]
[4
]
[5] (test-gh777-sec-end.aux)
Package tagpdf Info: Finalizing the tagging structure:
(tagpdf) Writing out ~38 structure objects
(tagpdf) with ~30 'MC' leaf nodes.
(tagpdf) Be patient if there are lots of objects!
Package tagpdf Info: writing ParentTree
Package tagpdf Info: writing IDTree
Package tagpdf Info: writing RoleMap
Package tagpdf Info: writing ClassMap
Package tagpdf Info: writing NameSpaces
Package tagpdf Info: writing StructElems
Package tagpdf Info: writing Root
Loading
Loading