Skip to content

Commit

Permalink
handle fakemath better with structelem latex3/tagging-project#764
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Nov 19, 2024
1 parent 7726e85 commit ada76e8
Show file tree
Hide file tree
Showing 6 changed files with 1,451 additions and 6 deletions.
4 changes: 4 additions & 0 deletions required/latex-lab/changes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2024-11-19 Ulrike Fischer <[email protected]>
* latex-lab-math.dtx: changed handling of math/mathml/structelem to better handle
fakemath (tagging/764)

2024-11-18 Joseph Wright <[email protected]>
* latex-lab-math.dtx: Use "@@" for a couple of internals

Expand Down
31 changes: 25 additions & 6 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-19}
\def\ltlabmathversion{0.6j}
%
%<*driver>
\documentclass{l3doc}
Expand Down Expand Up @@ -1169,6 +1169,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 +1194,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 @@ -1453,8 +1468,10 @@
{default}
% \end{macrocode}
% \changes{v0.6g}{2024-10-02}{disable paratagging, issue \#711}
% \changes{v0.6j}{2024-11-19}{activate structelem locally issue \#764}
% \begin{macrocode}
{ \tagpdfparaOff
\@@_luamml_structelem:
\tag_socket_use:n{math/content}
\tag_socket_use:n{math/struct/begin}
% \end{macrocode}
Expand Down Expand Up @@ -1523,6 +1540,7 @@
{tagsupport/math/display/formula/begin}
{default}
{
\@@_luamml_structelem:
\tag_socket_use:n{math/content}
\tag_socket_use:n{math/struct/begin}
\tag_socket_use:n{math/substruct/begin}
Expand Down Expand Up @@ -1945,6 +1963,7 @@
{ \tl_if_blank_p:n {#1} }
}
{
\@@_luamml_ignore:
#1 $ % $
}
{
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}
156 changes: 156 additions & 0 deletions required/latex-lab/testfiles-math-luatex/fakemath-error.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
This is a generated file for the l3build validation system.
Don't change this file in any respect.
Inserting mathml with Hash 8FD5BB0EEAA8887F6A312C99359A3B93
====>subpart splitting deactivated
====>grabbed math=macro:->a=b
Completed box being shipped out [1]
\vbox(627.36243+0.0)x380.0, direction TLT
.\hbox(0.0+0.0)x0.0, direction TLT
..\kern-72.26999
..\vbox(0.0+0.0)x0.0, glue set 72.26999fil, direction TLT
...\kern-72.26999
...\hbox(0.0+0.0)x0.0, direction TLT
....\pdfliteral page <lua data reference ...>
....\latelua0{ltx.__pdf.backend_ThisPage_gpush(tex.count["g_shipout_readonly_int"])}
....\glue 0.0 plus 1.0fil minus 1.0fil
...\glue 0.0 plus 1.0fil minus 1.0fil
.\glue 22.0
.\vbox(605.36243+0.0)x345.0, shifted 35.0, direction TLT
..\vbox(12.0+0.0)x345.0, glue set 5.55556fil, direction TLT
...\glue 0.0 plus 1.0fil
...\pdflinkstate 1
...\hbox(6.44444+0.0)x345.0, direction TLT
....\hbox(6.44444+0.0)x345.0, glue set 340.0fil, direction TLT
.....\glue 0.0 plus 1.0fil
.....\pdfliteral page <lua data reference ...>
.....\pdfliteral page <lua data reference ...>
.....\OT1/cmr/m/n/10 1
...\pdfliteral page <lua data reference ...>
...\pdfliteral page <lua data reference ...>
...\pdflinkstate 0
..\glue 18.06749
..\glue(\lineskip) 0.0
..\vbox(550.0+0.0)x345.0, glue set 528.0fil, direction TLT
...\latelua0{ltx.__pdf.Page.Resources.ExtGState=true}
...\latelua0{ltx.pdf.Page_Resources_gpush(tex.count["g_shipout_readonly_int"])}
...\write-{}
...\glue(\topskip) 3.05556
...\hbox(6.94444+2.22223)x345.0, glue set 177.25133fil, direction TLT
....\localpar
.....\localinterlinepenalty=0
.....\localbrokenpenalty=0
.....\localleftbox=null
.....\localrightbox=null
....\hbox(0.0+0.0)x15.0, direction TLT
....\pdfliteral page <lua data reference ...>
....\pdfliteral page <lua data reference ...>
....\mathon
....\OT1/cmtt/m/n/10 h
....\OT1/cmtt/m/n/10 t
....\OT1/cmtt/m/n/10 t
....\OT1/cmtt/m/n/10 p
....\OT1/cmtt/m/n/10 s
....\glue(\thickmuskip) 0.0
....\OT1/cmtt/m/n/10 :
....\penalty 500
....\glue(\thickmuskip) 0.0
....\OT1/cmtt/m/n/10 /
....\glue(\medmuskip) 0.0
....\OT1/cmtt/m/n/10 /
....\penalty 700
....\glue(\medmuskip) 0.0
....\OT1/cmtt/m/n/10 w
....\OT1/cmtt/m/n/10 w
....\OT1/cmtt/m/n/10 w
....\glue(\medmuskip) 0.0
....\OT1/cmtt/m/n/10 .
....\penalty 700
....\glue(\medmuskip) 0.0
....\OT1/cmtt/m/n/10 l
....\OT1/cmtt/m/n/10 a
....\OT1/cmtt/m/n/10 t
....\OT1/cmtt/m/n/10 e
....\OT1/cmtt/m/n/10 x
....\OT1/cmtt/m/n/10 -
....\hbox(0.0+0.0)x0.5, shifted 1.49998, direction TLT
.....\kern0.0 (font)
....\OT1/cmtt/m/n/10 p
....\OT1/cmtt/m/n/10 r
....\OT1/cmtt/m/n/10 o
....\OT1/cmtt/m/n/10 j
....\OT1/cmtt/m/n/10 e
....\OT1/cmtt/m/n/10 c
....\OT1/cmtt/m/n/10 t
....\glue(\medmuskip) 0.0
....\OT1/cmtt/m/n/10 .
....\penalty 700
....\glue(\medmuskip) 0.0
....\OT1/cmtt/m/n/10 o
....\OT1/cmtt/m/n/10 r
....\OT1/cmtt/m/n/10 g
....\mathoff
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue(\parskip) 0.0 plus 1.0
...\glue(\parskip) 0.0
...\glue(\baselineskip) 2.83333
...\hbox(6.94444+0.0)x345.0, glue set 307.08923fil, direction TLT
....\localpar
.....\localinterlinepenalty=0
.....\localbrokenpenalty=0
.....\localleftbox=null
.....\localrightbox=null
....\hbox(0.0+0.0)x15.0, direction TLT
....\pdfliteral page <lua data reference ...>
....\pdfliteral page <lua data reference ...>
....\mathon
....\pdfliteral page <lua data reference ...>
....\pdfliteral page <lua data reference ...>
....\OML/cmm/m/it/10 a
....\glue(\thickmuskip) 2.77771 plus 2.77771
....\pdfliteral page <lua data reference ...>
....\pdfliteral page <lua data reference ...>
....\OT1/cmr/m/n/10 =
....\penalty 500
....\glue(\thickmuskip) 2.77771 plus 2.77771
....\pdfliteral page <lua data reference ...>
....\pdfliteral page <lua data reference ...>
....\OML/cmm/m/it/10 b
....\pdfliteral page <lua data reference ...>
....\pdfliteral page <lua data reference ...>
....\mathoff
....\penalty 10000
....\glue(\parfillskip) 0.0 plus 1.0fil
....\glue(\rightskip) 0.0
...\glue 0.0 plus 1.0fil
...\glue 0.0
..\pdflinkstate 1
..\glue(\baselineskip) 25.29494
..\hbox(0.0+0.0)x345.0, direction TLT
...\hbox(0.0+0.0)x345.0, direction TLT
..\pdflinkstate 0
.\kern0.0
.\kern-627.36243
.\hbox(0.0+0.0)x0.0, direction TLT
.\kern627.36243
.\pdfliteral page <lua data reference ...>
(fakemath-error.aux)
MathML statistic
================
==> 1 MathML fragments read
==> 1 different MathML fragments
==> 1 math fragments found
==> 1 fitting MathML AF found
==> 1 MathML AF attached
Package tagpdf Info: Finalizing the tagging structure:
(tagpdf) Writing out ~13 structure objects
(tagpdf) with ~9 '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
20 changes: 20 additions & 0 deletions required/latex-lab/testfiles-math-luatex/fakemath.pvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
\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}

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

$a=b$


\begin{equation}
x=\int f(y)
\end{equation}
\end{document}
Loading

0 comments on commit ada76e8

Please sign in to comment.