[latex3-commits] [latex3/latex2e] latex-lab/uf-review-05: switch to html reader (32c5cf29)
github at latex-project.org
github at latex-project.org
Mon Jan 22 23:32:24 CET 2024
Repository : https://github.com/latex3/latex2e
On branch : latex-lab/uf-review-05
Link : https://github.com/latex3/latex2e/commit/32c5cf2985be4ea2e50c12796a6b5f8c4b1632af
>---------------------------------------------------------------
commit 32c5cf2985be4ea2e50c12796a6b5f8c4b1632af
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Mon Jan 22 23:32:24 2024 +0100
switch to html reader
>---------------------------------------------------------------
32c5cf2985be4ea2e50c12796a6b5f8c4b1632af
required/latex-lab/latex-lab-math.dtx | 66 ++++++++++------------
.../support/mathml-AF-ex1-mathml.html | 45 +++++++++++++++
2 files changed, 75 insertions(+), 36 deletions(-)
diff --git a/required/latex-lab/latex-lab-math.dtx b/required/latex-lab/latex-lab-math.dtx
index 282d7b95..6d6acbd1 100644
--- a/required/latex-lab/latex-lab-math.dtx
+++ b/required/latex-lab/latex-lab-math.dtx
@@ -251,32 +251,12 @@
% If the equation is numbered the numbering should be part of the MathML as
% the |Lbl| substructure is ignored if an MathML is used (see https://github.com/foxitsoftware/PDF_UA-2).
%
-% Currently two input syntax for the MathML
-% are supported\footnote{We do not expect
-% both formats to stay. Experience will show which one is more useful and if more
-% adaptions are needed.}:
-% \begin{description}
-% \item[xml/tex-format]
-% The file can start with \verb|<x>| and end with \verb|</x>| to make it a valid
-% xml-file that can be validated.
-% It should have the extension \texttt{.xml}.
-% The file should contain a number of representations in this format:
-% \begin{syntax}
-% \cs{mml}\Arg{key}\Arg{source}\Arg{hash}\Arg{mathml}
-% \end{syntax}
-%
-% The file is read in with the catcodes of \texttt{\#} and \texttt{\%} set to other
-% so that they can be used in the \meta{mathml}. But braces must be correctly balanced.
-%
-% \meta{key} and \meta{source} are currently only used for debugging, they help to identify
-% the equation referred by this representation. \meta{hash} is a hash key and is used
-% to identify the equation to which the MathML should be attached. If the equation is changed
-% it must be adapted. \meta{mathml} is the MathML representation.
-%
-% \item[\texttt{html}-format] A second format is meant to be a valid html file
-% to view and check the mathml representation of the math in a browser.
+% The MathML representation is given in a special format.
+% It is meant to be a valid html file
+% that can be viewed in a browser.
% For this it can start with |<!DOCTYPE html><html>| and end with |</html>|
-% It should have the extension \texttt{.html}.
+% It should have the extension \texttt{.html}. The file is read in with
+% special catcodes, so can contain hashes and comment chars.
%
% The file should contain a number of representations in this format:
% \begin{quote}
@@ -289,10 +269,10 @@
% | </math>|\\
% |</div>|
% \end{quote}
-% The html tags |<div>|, |h2|, |<p>|, |<math|, |</math>| |</dvi>| are required as
+% The keywords |<div>|, |<h2>\mml|, |<p>|, |<math|, |</math>| |</div>| are required as
% they are used to delimit the arguments by the \LaTeX{} code.
%
-% |\mml|, \meta{key} and \meta{source} are only used for debugging, they help to identify
+% \meta{key} and \meta{source} are only used for debugging, they help to identify
% the equation referred by this representation. The source should be used correctly escaped
% |&| and |<| so that if gives valid html!
%
@@ -308,10 +288,8 @@
%
% By default the code tries at the begin of the document
% to read a file |\jobname-mathml.html| in the |html|-format.
-% The input format can be changed to the |xml/tex| format with
-% |mathml/input=xml/tex|.
% The file name can be changed with |mathml/setfiles={filename1,filename2}|
-% (without extension, |html| or |xml| is added automatically).
+% (without extension, |html| is added automatically).
% If there is a list, all files are loaded.
% If a file doesn't exist it is ignored, only an info is written to the log.
%
@@ -638,7 +616,7 @@
% \end{macrocode}
% \end{variable}
-% This is the internal variant of the \cs{mml} command
+% This is the internal variant of the \cs{mml} command.
% \begin{macro}{\@@_AF_mml:nnnn}
% \begin{macrocode}
\cs_new_protected:Npn \@@_AF_mml:nnnn #1 #2 #3 #4
@@ -668,6 +646,22 @@
}
% \end{macrocode}
% \end{macro}
+%
+% The html reader.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_AF_html_reader:w#1</h2>#2<p>#3</p>#4<p>#5</p>#6<math{
+ \begingroup
+ \let\do\@makeother \dospecials
+ \@@_AF_html_reader_verb:w{#1}{#3}{#5}<math
+}
+% \end{macrocode}
+% \begin{macrocode}
+\cs_new_protected:Npn\@@_AF_html_reader_verb:w#1#2#3#4~</div>{
+ \endgroup
+ \@@_AF_mml:nnnn{#1}{#2}{#3}{#4}
+ }
+% \end{macrocode}
+
%
% \begin{socketdecl}{tagsupport/math/mathml/write}
% This writes a html-template with the hash and the math content.
@@ -705,13 +699,14 @@
% \end{macrocode}
% \end{plugdecl}
% And now a key to activate the socket.
-% There should be a test so
+% TODO: There should be a test if the stream is already open.
% \begin{macrocode}
\keys_define:nn { math / tagging }
{
mathml/writehash .code:n =
{
+ \bool_gset_true:N \g__tag_math_mathml_AF_bool
\iow_new:N \g_@@_writehash_iow
\iow_open:Nn \g_@@_writehash_iow
{
@@ -736,13 +731,13 @@
{ l_pdffile }{Subtype}
{ \pdf_name_from_unicode_e:n{application/mathml+xml} }
\char_set_catcode_other:N \#
- \cs_set_eq:NN\mml \@@_AF_mml:nnnn
+ \cs_set_eq:NN\mml \@@_AF_html_reader:w
\clist_map_inline:Nn \l__tag_math_mathml_files_clist
{
- \file_if_exist:nTF {##1.xml}
+ \file_if_exist:nTF {##1.html}
{
\typeout{Info:~reading~mathml~file~##1}
- \file_input:n {##1.xml}
+ \file_input:n {##1.html}
\bool_gset_true:N\g__tag_math_mathml_AF_bool
}
{
@@ -825,7 +820,6 @@
mathml/panel .bool_set:N = \l__tag_math_mathml_panel_bool,
mathml/panel .initial:n = true,
texsource/panel .bool_set:N = \l__tag_math_texsource_panel_bool,
- mathml/activate .bool_gset:N = \g__tag_math_mathml_AF_bool
}
% \end{macrocode}
%
diff --git a/required/latex-lab/testfiles-math/support/mathml-AF-ex1-mathml.html b/required/latex-lab/testfiles-math/support/mathml-AF-ex1-mathml.html
new file mode 100644
index 00000000..304546ca
--- /dev/null
+++ b/required/latex-lab/testfiles-math/support/mathml-AF-ex1-mathml.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+
+<div>
+<h2>\mml 1</h2>
+<p>\begin{math}x\end{math}</p>
+<p>9DD4E461268C8034F5C8564E155C67A6</p>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
+ <mi>x</mi>
+</math>
+</div>
+
+<div>
+<h2>\mml 2</h2>
+<p>\begin{math}y\end{math}</p>
+<p>415290769594460E2E485922904F345D</p>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
+ <mi>y</mi>
+</math>
+</div>
+
+<div>
+<h2>\mml 3</h2>
+<p>\begin{math}x>y\end{math}</p>
+<p>10342149CD04422C7BE79506CB544AC5</p>
+<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline">
+ <mi>x</mi>
+ <mo>></mo>
+ <mi>y</mi>
+</math>
+</div>
+
+
+<div>
+<h2>\mml 4</h2>
+<p>\begin{equation*}\sqrt{x^2}=\lvert x\rvert\end{equation*}</p>
+<p>D618B2AAA114982934BBC21847962F30</p>
+<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>
+</div>
+
+</html>
More information about the latex3-commits
mailing list.