Skip to content

Commit

Permalink
tagging Issue 764, 765 (#1553)
Browse files Browse the repository at this point in the history
* handle fakemath better with structelem latex3/tagging-project#764

* switch to tagging socket WIP

* update tagpdf to 0.99i

* move tagpdfparaOff (latex3/tagging-project#765)

* issue 765, WIPgit add -p  mtag-007 is wrong

* remove unneeded tagpdfparaOn

* testfiles for latex3/tagging-project#765

* different error

* from review
  • Loading branch information
u-fischer authored Nov 26, 2024
1 parent df4eee8 commit 110cc0a
Show file tree
Hide file tree
Showing 13 changed files with 4,079 additions and 78 deletions.
7 changes: 7 additions & 0 deletions required/latex-lab/changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2024-11-26 Ulrike Fischer <[email protected]>
* latex-lab-math.dtx: changed handling of math/mathml/structelem to handle
fakemath better(tagging/764)
* latex-lab-math.dtx: made all main math sockets tagging sockets and
assign the plugs directly.
* disable para tagging also in $$-display (tagging/765)

2024-11-23 Frank Mittelbach <[email protected]>

* latex-lab-block.dtx (subsubsection{Implementation of block templates \ldots}):
Expand Down
115 changes: 52 additions & 63 deletions required/latex-lab/latex-lab-math.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
% for those people who are interested or want to report an issue.
%
%
\def\ltlabmathdate{2024-11-18}
\def\ltlabmathversion{0.6i}
\def\ltlabmathdate{2024-11-26}
\def\ltlabmathversion{0.6j}
%
%<*driver>
\documentclass{l3doc}
Expand Down Expand Up @@ -205,11 +205,8 @@
% The actual tagging is in done through the sockets
% \begin{itemize}
% \item |tagsupport/math/inline/formula/begin|
% This socket takes the math as argument and its code
% This socket takes the math as second argument and its code
% should output it for typesetting.
% It is not \emph{used} as a tagging socket as the math argument should
% not be lost without tagging, so without tagging the
% socket uses the identity plug.
% The |default| plug of the socket calls these three internal sockets
% for the tagging support:
% \begin{itemize}
Expand Down Expand Up @@ -1169,6 +1166,13 @@
\bool_gset_true:N \g_@@_luamml_write_bool
% \end{macrocode}
% \end{variable}
% \begin{macro}{\@@_luamml_ignore:,\@@_luamml_structelem:}
% Internal variants of the luamml commands, that can be remapped if needed.
% \begin{macrocode}
\cs_new:Npn\@@_luamml_structelem:{}
\cs_new:Npn\@@_luamml_ignore:{}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\msg_new:nnn { tag }{ PDF-2.0-recommended }
Expand All @@ -1187,18 +1191,26 @@
math/mathml/luamml/load .default:n = true,
math/mathml/luamml/load .usage:n=preamble,
% \end{macrocode}
% A key to activate math structure elements. It shouldn't
% be issued in the preamble as luamml is not yet loaded.
% A key to activate math structure elements.
% \changes{v0.6j}{2024-11-19}{no longer enable globally for better fake math handling, issue \#764}
% \begin{macrocode}
math/mathml/structelem .code:n =
math/mathml/structelem .choice:,
math/mathml/structelem/true .code:n =
{
\pdf_version_compare:NnT < {2.0}
{
\msg_warning:nnne { tag }{ PDF-2.0-recommended }
{ math/mathml/structelem }{ \pdf_version: }
}
\AddToHook{begindocument/end}{\luamml_structelem:}
\cs_set:Npn\@@_luamml_structelem:{\luamml_structelem:}
\cs_set:Npn\@@_luamml_ignore:{\luamml_ignore:}
},
math/mathml/structelem/false .code:n =
{
\cs_set_eq:NN\@@_luamml_structelem:\prg_do_nothing:
\cs_set_eq:NN\@@_luamml_ignore:\prg_do_nothing:
},
math/mathml/structelem .default:n = true,
% \end{macrocode}
% and a key to call the ignore flag. This should only be used locally.
% \begin{macrocode}
Expand Down Expand Up @@ -1423,10 +1435,12 @@
% The formula sockets are despite their naming not symmetric:
% the begin socket is issued after the math has started, while
% the end socket is after the math!
% \changes{v0.6j}{2024-11-19}{change the socket to two arguments so that it can
% be used as tagging socket}
% \begin{macrocode}
\socket_new:nn {tagsupport/math/inline/begin}{0}
\socket_new:nn {tagsupport/math/inline/end}{0}
\socket_new:nn {tagsupport/math/inline/formula/begin}{1} %
\socket_new:nn {tagsupport/math/inline/formula/begin}{2} %
\socket_new:nn {tagsupport/math/inline/formula/end}{0}
% \end{macrocode}
%\end{socketdecl}
Expand All @@ -1453,16 +1467,19 @@
{default}
% \end{macrocode}
% \changes{v0.6g}{2024-10-02}{disable paratagging, issue \#711}
% \changes{v0.6j}{2024-11-19}{activate structelem locally issue \#764}
% \changes{v0.6j}{2024-11-19}{change to two arguments}
% \begin{macrocode}
{ \tagpdfparaOff
\@@_luamml_structelem:
\tag_socket_use:n{math/content}
\tag_socket_use:n{math/struct/begin}
% \end{macrocode}
% TODO: does inline math need subformula handling?
% \begin{macrocode}
% inner formula if multiple parts (not really implemented yet)
\tag_socket_use:n{math/substruct/begin}
#1
#2
\tag_socket_use:n{math/end}
}
\socket_new_plug:nnn
Expand Down Expand Up @@ -1491,13 +1508,11 @@
% The formula sockets are despite their naming not symmetric:
% the begin socket is issued after the math has started, while
% the end socket is after the math!
% The socket |tagsupport/math/display/formula/begin| should similar to
% the inline version not be used as tagging socket so that the argument, the math,
% is not lost.
% \changes{v0.6j}{2024-11-19}{change number of arguments of formula/begin socket}
% \begin{macrocode}
\socket_new:nn {tagsupport/math/display/begin}{0}
\socket_new:nn {tagsupport/math/display/end}{0}
\socket_new:nn {tagsupport/math/display/formula/begin}{1} %
\socket_new:nn {tagsupport/math/display/formula/begin}{2} %
\socket_new:nn {tagsupport/math/display/formula/end}{0}
% \end{macrocode}
%\end{socketdecl}
Expand All @@ -1518,15 +1533,18 @@


% \begin{plugdecl}{default}
% \changes{v0.6j}{2024-11-19}{moved \cs{tagpdfparaOff} into the socket, tagging/765}
% \begin{macrocode}
\socket_new_plug:nnn
{tagsupport/math/display/formula/begin}
{default}
{
\tagpdfparaOff
\@@_luamml_structelem:
\tag_socket_use:n{math/content}
\tag_socket_use:n{math/struct/begin}
\tag_socket_use:n{math/substruct/begin}
#1
#2
\tag_socket_use:n{math/end}
}
\socket_new_plug:nnn
Expand Down Expand Up @@ -1833,48 +1851,21 @@
\socket_new:nn {tagsupport/math/end}{0}
% \end{macrocode}
% \end{socketdecl}

%
% \begin{macro}{\__tag_math_disable:}
% Similar to the table code we collect the plugs that should be
% assigned to do nothing if we don't want tagging
% \begin{macrocode}
\cs_new_protected:Npn \__tag_math_disable:
{
\socket_assign_plug:nn {tagsupport/math/inline/begin}{noop}
\socket_assign_plug:nn {tagsupport/math/inline/end}{noop}
\socket_assign_plug:nn {tagsupport/math/inline/formula/begin}{identity}
\socket_assign_plug:nn {tagsupport/math/inline/formula/end}{noop}
\socket_assign_plug:nn {tagsupport/math/display/begin}{noop}
\socket_assign_plug:nn {tagsupport/math/display/end}{noop}
\socket_assign_plug:nn {tagsupport/math/display/formula/begin}{identity}
\socket_assign_plug:nn {tagsupport/math/display/formula/end}{noop}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\__tag_math_enable:}
% Similar to the table code we collect the default plugs that should be
% assigned if we want tagging
% \changes{v0.6j}{2024-11-19}{removed enable/disable command and assign tagging sockets directly}
% \begin{macrocode}
\cs_new_protected:Npn \__tag_math_enable:
{
\socket_assign_plug:nn {tagsupport/math/inline/begin}{MC}
\socket_assign_plug:nn {tagsupport/math/inline/end}{MC}
\socket_assign_plug:nn {tagsupport/math/inline/formula/begin}{default}
\socket_assign_plug:nn {tagsupport/math/inline/formula/end}{default}
\socket_assign_plug:nn {tagsupport/math/display/begin}{default}
\socket_assign_plug:nn {tagsupport/math/display/end}{default}
\socket_assign_plug:nn {tagsupport/math/display/formula/begin}{default}
\socket_assign_plug:nn {tagsupport/math/display/formula/end}{default}
}
% \end{macrocode}
% \end{macro}
% At begin document we can activate:
% \begin{macrocode}
\AtBeginDocument{\tag_if_active:T{\__tag_math_enable: }}
\socket_assign_plug:nn {tagsupport/math/inline/begin}{MC}
\socket_assign_plug:nn {tagsupport/math/inline/end}{MC}
\socket_assign_plug:nn {tagsupport/math/inline/formula/begin}{default}
\socket_assign_plug:nn {tagsupport/math/inline/formula/end}{default}
\socket_assign_plug:nn {tagsupport/math/display/begin}{default}
\socket_assign_plug:nn {tagsupport/math/display/end}{default}
\socket_assign_plug:nn {tagsupport/math/display/formula/begin}{default}
\socket_assign_plug:nn {tagsupport/math/display/formula/end}{default}
% \end{macrocode}
%
%
% \subsection{Interface commands}
%
% \begin{macro}
Expand Down Expand Up @@ -1945,15 +1936,17 @@
{ \tl_if_blank_p:n {#1} }
}
{
\@@_luamml_ignore:
#1 $ % $
}
{
\tag_socket_use:n {math/inline/begin} %end P-MC
% \end{macrocode}
% We do no use a tagging socket here, so that the argument (the
% math) is not lost, tagging-project issue 661.
% \changes{v0.6j}{2024-11-19}{change socket to tagging socket}
% \begin{macrocode}
\socket_use:nn {tagsupport/math/inline/formula/begin}{#1}
\tag_socket_use:nnn {math/inline/formula/begin}{}{#1}
$ % $
\tag_socket_use:n {math/inline/formula/end}
\tag_socket_use:n {math/inline/end} % restart P-MC
Expand Down Expand Up @@ -1982,25 +1975,22 @@
{
\@@_process:nn { equation* } {#1}
\tag_socket_use:n {math/display/begin}
\socket_use:nn{tagsupport/math/display/formula/begin}{#1}
\tag_socket_use:nn{math/display/formula/begin}{}{#1}
}
$$
}
% \end{macrocode}
%
% The end code is added through a \cs{aftergroup} so we
% store it inside a command.
% \changes{v0.6j}{2024-11-19}{removed unneeded \cs{tagpdfparaOn}}
% \begin{macrocode}
\cs_new_protected:Npn \@@_tag_dollardollar_display_end:
{
% \typeout{== tag dollarldollar display end}
% \ShowTagging{struct-stack}
\para_raw_end:
% \end{macrocode}
% TODO why is that needed? where is para-tagging disabled?
% \begin{macrocode}
\tagpdfparaOn
% \end{macrocode}
% The \cs{postdisplaypenalty} was temporarily set to 10000 inside
% the display and the \cs{belowdisplayskip} and the
% \cs{belowdisplayshortskip} was negated, so whatever was inserted
Expand Down Expand Up @@ -2399,16 +2389,15 @@
% \typeout{==>A3}
\__tag_tool_close_P:
}
\socket_use:nn{tagsupport/math/display/formula/begin}{}
\tagpdfparaOff
\tag_socket_use:nn{math/display/formula/begin}{}{}
% \typeout{==>MC1}\ShowTagging{mc-current}
}
\cs_new:Npn \@kernel@math@registered@end {
% \typeout{==>MC2}\ShowTagging{mc-current}
\para_raw_end:
\tagpdfparaOn
\socket_use:n{tagsupport/math/display/formula/end}
\tag_socket_use:n{tagsupport/math/display/formula/end}
% \typeout{==>MC3}\ShowTagging{mc-current}
\@endpetrue
}
Expand Down
18 changes: 18 additions & 0 deletions required/latex-lab/testfiles-math-luatex/fakemath-error.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\ExplSyntaxOn
\sys_gset_rand_seed:n{42}
\ExplSyntaxOff
\DocumentMetadata{testphase={phase-III,math},pdfversion=2.0}
\input{regression-test}
\documentclass{book}
\usepackage{url}
\tagpdfsetup{math/mathml/structelem}
\tagpdfsetup{math/mathml/luamml/load}
\begin{document}
\START
\showoutput

\url{https://www.latex-project.org}

$a=b$

\end{document}
Loading

0 comments on commit 110cc0a

Please sign in to comment.