diff --git a/required/latex-lab/latex-lab-math.dtx b/required/latex-lab/latex-lab-math.dtx
index dc7ccbeb1..7c4cbfd62 100644
--- a/required/latex-lab/latex-lab-math.dtx
+++ b/required/latex-lab/latex-lab-math.dtx
@@ -494,7 +494,7 @@
% \end{macrocode}
% \end{variable}
%
-% \begin{variable}{\l_@@_tmpa_tl,\l_@@_tmpa_skip}
+% \begin{variable}{\l_@@_tmpa_tl,\l_@@_tmpa_skip,\l_@@_tmpa_str}
% Temporary variables
% \begin{macrocode}
\tl_new:N \l_@@_tmpa_tl
@@ -615,6 +615,62 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{socketdecl}{tagsupport/math/mathml/write}
+% This writes a html-template with the hash and the math content.
+% This should be optional, so it uses a socket that can be disabled
+%
+% \begin{macrocode}
+\socket_new:nn {tagsupport/math/mathml/write}{0}
+% \end{macrocode}
+% \end{socketdecl}
+%
+% \begin{plugdecl}{On}
+% \begin{macrocode}
+\socket_new_plug:nnn{tagsupport/math/mathml/write}{On}
+ {
+ \str_set:NV\l_@@_tmpa_str\l_@@_content_AF_source_tl
+ \str_replace_all:Nnn\l_@@_tmpa_str{&}{&}
+ \str_replace_all:Nnn\l_@@_tmpa_str{<}{<}
+ \iow_now:Ne \g_@@_writehash_iow
+ {
+ \iow_newline:
+
+ \iow_newline:
+
\c_backslash_str mml\c_space_tl \int_use:N \g_@@_AF_total_int
+ \iow_newline:
+
\l_@@_tmpa_str
+ \iow_newline:
+
\l_@@_content_hash_tl
+ \iow_newline:
+
+ \iow_newline:
+
+ \iow_newline:
+ }
+ }
+% \end{macrocode}
+% \end{plugdecl}
+% And now a key to activate the socket.
+% There should be a test so
+% \begin{macrocode}
+
+\keys_define:nn { math / tagging }
+ {
+ mathml/writehash .code:n =
+ {
+ \iow_new:N \g_@@_writehash_iow
+ \iow_open:Nn \g_@@_writehash_iow
+ {
+ \c_sys_jobname_str-mathml-template.html
+ }
+ \AssignSocketPlug {tagsupport/math/mathml/write}{On}
+ },
+ mathml/writehash .usage:n=preamble
+ }
+
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\@@_AF_process_mathml_files:}
% \begin{macrocode}
\box_new:N\l_@@_tmpa_box
@@ -715,7 +771,8 @@
mathml/setfiles .clist_set:N = \l__tag_math_mathml_files_clist,
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,
+ texsource/panel .bool_set:N = \l__tag_math_texsource_panel_bool,
+ mathml/activate .bool_gset:N = \g__tag_math_mathml_AF_bool
}
% \end{macrocode}
%
@@ -1019,6 +1076,7 @@
{
\typeout{WARNING:~mathml~missing~for~hash\l_@@_content_hash_tl}
}
+ \socket_use:n {tagsupport/math/mathml/write} % write hash if request
\tag_struct_begin:n
{
tag=Formula,