[latex3-commits] [latex3/latex2e] latex-lab/uf-review-05: add mathml statistic (905f2e80)

github at latex-project.org github at latex-project.org
Thu Jan 18 00:29:39 CET 2024


Repository : https://github.com/latex3/latex2e
On branch  : latex-lab/uf-review-05
Link       : https://github.com/latex3/latex2e/commit/905f2e80dc2499cfef2572ca4796fc40c406ee1a

>---------------------------------------------------------------

commit 905f2e80dc2499cfef2572ca4796fc40c406ee1a
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Thu Jan 18 00:29:39 2024 +0100

    add mathml statistic


>---------------------------------------------------------------

905f2e80dc2499cfef2572ca4796fc40c406ee1a
 required/latex-lab/changes.txt                     |  1 +
 required/latex-lab/latex-lab-math.dtx              | 39 ++++++++++++++++++--
 .../latex-lab/testfiles-math/mathml-AF-ex1.lvt     | 24 ++++++++++++
 .../latex-lab/testfiles-math/mathml-AF-ex1.tlg     | 22 +++++++++++
 .../support/mathml-AF-ex1-mathml.xml               | 43 ++++++++++++++++++++++
 5 files changed, 125 insertions(+), 4 deletions(-)

diff --git a/required/latex-lab/changes.txt b/required/latex-lab/changes.txt
index 5c19494b..e17d45ef 100644
--- a/required/latex-lab/changes.txt
+++ b/required/latex-lab/changes.txt
@@ -1,6 +1,7 @@
 2024-01-17 Ulrike Fischer <Ulrike.Fischer at latex-project.org> 
 	* latex-lab-math.dtx, latex-lab-amsmath.dtx, redefine \text to 
 	avoid faulty structure and faulty PDF from \mathchoice.
+	Add statistic for mathml handling.
 
 2024-01-14 Ulrike Fischer <Ulrike.Fischer at latex-project.org> 
 	* latex-lab-float.dtx, correct destination, see tagging issue #55
diff --git a/required/latex-lab/latex-lab-math.dtx b/required/latex-lab/latex-lab-math.dtx
index 16837a36..dc7ccbeb 100644
--- a/required/latex-lab/latex-lab-math.dtx
+++ b/required/latex-lab/latex-lab-math.dtx
@@ -2,7 +2,7 @@
 %
 %% File: latex-lab-math.dtx
 %
-% Copyright (C) 2022-2023 The LaTeX Project
+% Copyright (C) 2022-2024 The 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
@@ -19,8 +19,8 @@
 % for those people who are interested or want to report an issue.
 %
 %
-\def\ltlabmathdate{2023-11-12}
-\def\ltlabmathversion{0.5f}
+\def\ltlabmathdate{2024-01-18}
+\def\ltlabmathversion{0.5g}
 %
 %<*driver>
 \documentclass{l3doc}
@@ -562,6 +562,20 @@
 %    \end{macrocode}
 % \end{variable}
 % 
+% \begin{variable}{\g_@@_mml_total_int,\g_@@_mml_int,\g_@@_AF_total_int,\g_@@_AF_found_int}
+% \cs{g_@@_mml_total_int} records the mathml fragments read in.
+% \cs{g_@@_mml_int} records the mathml fragments read in with a different hash.
+% \cs{g_@@_AF_total_int} records the number of math structures that try to 
+% attach a mathml AF. 
+% \cs{g_@@_AF_found_int} records the number of math structures which got a mathml fragment.
+%    \begin{macrocode}
+\int_new:N\g_@@_mml_total_int
+\int_new:N\g_@@_mml_int
+\int_new:N\g_@@_AF_total_int
+\int_new:N\g_@@_AF_found_int
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{variable}{\l__tag_math_mathml_files_clist}
 % A sequence to store the file list for the mathml.
 %    \begin{macrocode}
@@ -576,11 +590,13 @@
 \cs_new_protected:Npn \@@_AF_mml:nnnn #1 #2 #3 #4
 %#1 number, #2 tex source for debugging, #3 hash, #4 mathml
   {
+    \int_gincr:N \g_@@_mml_total_int
 %    \end{macrocode}
-    % mathml with the same hash should be included only once:
+% mathml with the same hash should be included only once:
 %    \begin{macrocode}
     \tl_if_exist:cF { g_@@_mathml_#3_tl }
      {
+       \int_gincr:N \g_@@_mml_int
 %    \end{macrocode}
 %  a simple Desc key, take care that it is a valid string!
 %    \begin{macrocode}
@@ -635,6 +651,19 @@
 %    \begin{macrocode}
         \AssignSocketPlug{tagsupport/math/substruct/begin}{single}
         \AssignSocketPlug{tagsupport/math/substruct/end}{single}
+        \AddToHook{enddocument/info}
+         {
+           \iow_term:n{MathML~statistic}
+           \iow_term:n{================}
+           \iow_term:e{==>~\int_use:N\g_@@_mml_total_int\c_space_tl 
+           MathML~fragments~read}
+           \iow_term:e{==>~\int_use:N\g_@@_mml_int\c_space_tl 
+           different~MathML~fragments}
+           \iow_term:e{==>~\int_use:N\g_@@_AF_total_int\c_space_tl 
+           math~fragments~found}
+           \iow_term:e{==>~\int_use:N\g_@@_AF_found_int\c_space_tl 
+           MathML~AF~attached}
+         }
       }  
  }
 \AddToHook{begindocument}{\@@_AF_process_mathml_files:} 
@@ -968,6 +997,7 @@
   {tagsupport/math/struct/begin}
   {test-mathml}
   { 
+   \int_gincr:N\g_@@_AF_total_int  
    \tl_set:Ne\l_@@_content_hash_tl 
     {\str_mdfive_hash:o { \g_@@_grabbed_math_tl }} 
    \tl_set_eq:NN\l_@@_grabbed_math_tl\g_@@_grabbed_math_tl   
@@ -983,6 +1013,7 @@
 %    \begin{macrocode}
    \tl_if_exist:cTF { g_@@_mathml_ \l_@@_content_hash_tl _tl }
     {  
+      \int_gincr:N\g_@@_AF_found_int                                
       \typeout {Inserting~mathml~with~Hash~\l_@@_content_hash_tl}    
     }
     {
diff --git a/required/latex-lab/testfiles-math/mathml-AF-ex1.lvt b/required/latex-lab/testfiles-math/mathml-AF-ex1.lvt
new file mode 100644
index 00000000..c3f5b527
--- /dev/null
+++ b/required/latex-lab/testfiles-math/mathml-AF-ex1.lvt
@@ -0,0 +1,24 @@
+\ExplSyntaxOn
+\sys_gset_rand_seed:n{1000}
+\ExplSyntaxOff
+\DocumentMetadata{testphase={phase-III,math,table,title}, pdfversion=2.0, 
+ pdfstandard=ua-2,
+}
+\input{regression-test}
+\documentclass{article}
+
+\begin{document}
+\START
+\title{Math Test One}
+\author{David}
+\maketitle
+
+\section{Math Tests}
+
+Some inline math, let $x$ and $y$ satisfy $x>y$.
+
+Some text, and an equation.
+\[
+\sqrt{x^2}=\lvert x\rvert
+\]
+\end{document}
diff --git a/required/latex-lab/testfiles-math/mathml-AF-ex1.tlg b/required/latex-lab/testfiles-math/mathml-AF-ex1.tlg
new file mode 100644
index 00000000..a4e0575f
--- /dev/null
+++ b/required/latex-lab/testfiles-math/mathml-AF-ex1.tlg
@@ -0,0 +1,22 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+Inserting mathml with Hash 9DD4E461268C8034F5C8564E155C67A6
+====>subpart splitting deactivated
+====>grabbed math=macro:->x
+Inserting mathml with Hash 415290769594460E2E485922904F345D
+====>subpart splitting deactivated
+====>grabbed math=macro:->y
+Inserting mathml with Hash 10342149CD04422C7BE79506CB544AC5
+====>subpart splitting deactivated
+====>grabbed math=macro:->x>y
+Inserting mathml with Hash D618B2AAA114982934BBC21847962F30
+====>subpart splitting deactivated
+====>grabbed math=macro:->\sqrt {x^2}=\lvert x\rvert 
+[1
+] (mathml-AF-ex1.aux)
+MathML statistic
+================
+==> 4 MathML fragments read
+==> 4 different MathML fragments
+==> 4 math fragments found
+==> 4 MathML AF attached
diff --git a/required/latex-lab/testfiles-math/support/mathml-AF-ex1-mathml.xml b/required/latex-lab/testfiles-math/support/mathml-AF-ex1-mathml.xml
new file mode 100644
index 00000000..4d338e57
--- /dev/null
+++ b/required/latex-lab/testfiles-math/support/mathml-AF-ex1-mathml.xml
@@ -0,0 +1,43 @@
+<x>
+
+ \mml{1}
+  {\begin{math}x\end{math}}
+  {9DD4E461268C8034F5C8564E155C67A6}
+  {<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
+ <mi>x</mi>
+</math>%
+}
+
+\mml{2}
+{\begin{math}y\end{math}}
+{415290769594460E2E485922904F345D}
+{%
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
+ <mi>y</mi>
+</math>%
+}
+
+\mml{3}
+{\begin{math}x>y\end{math}}
+{10342149CD04422C7BE79506CB544AC5}
+{%
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
+ <mi>x</mi>
+ <mo>></mo>
+ <mi>y</mi>
+</math>%
+}
+
+
+\mml{4}
+{\begin{equation*}\sqrt{x^2}=\lvert x\rvert\end{equation*}}
+{D618B2AAA114982934BBC21847962F30}
+{%
+<math xmlns="http://www.w3.org/1998/Math/MathML">
+ <msqrt><msup><mi>x</mi><mn>2</mn></msup></msqrt>
+ <mo>=</mo>
+ <mrow intent="absolute-value($x)"><mo>|</mo><mi arg="x">x</mi><mo>|</mo></mrow>
+</math>%
+}
+
+</x>





More information about the latex3-commits mailing list.