Patch \text

This commit is contained in:
Marcel Fabian Krüger 2021-11-01 06:47:55 +01:00
parent c6a180cd1a
commit f132e3496a
4 changed files with 62 additions and 3 deletions

View File

@ -0,0 +1,37 @@
\ProvidesExplPackage {luamml-patches-amstext} {2021-04-23} {0.0.1-alpha}
{Feel free to add a description here}
\int_new:N \g__luamml_amsmath_text_struct_int
\cs_set:Npn \textdef@ #1 #2 #3 {
\int_if_odd:nTF { \int_div_truncate:nn { \l__luamml_flag_int } { 8 } } {
\int_gincr:N \g__luamml_amsmath_text_struct_int
\tag_struct_begin:n {
tag = mtext/mathml,
stash,
label = __luamml_amsmath_text_ \int_use:N \g__luamml_amsmath_text_struct_int
}
\tag_mc_begin:n {
tag = mtext
}
\AnnotateFormula {
nucleus = true,
struct = "__luamml_amsmath_text_ \int_use:N \g__luamml_amsmath_text_struct_int"
}
} {
\use_i:n
}
{
\hbox {
{
\everymath {#1}
\let \f@size #2
\selectfont
#3
}
}
}
\int_if_odd:nT { \int_div_truncate:nn { \l__luamml_flag_int } { 8 } } {
\tag_mc_end:
\tag_struct_end:
}
}

View File

@ -59,7 +59,21 @@ local function annotate()
props = {}
properties[marked] = props
end
if annotation.core then
props.mathml_core = annotation.core
end
if annotation.struct then
local saved = props.mathml_filter
local struct = annotation.struct
function props.mathml_filter(mml, core)
mml[':struct'] = struct
if saved then
return saved(mml, core)
else
return mml, core
end
end
end
else
tex.error'Unable to annotate nucleus of node without nucleus'
end

View File

@ -450,6 +450,7 @@
% \begin{macrocode}
\RequirePackage { luamml-patches-kernel }
%<*luatex>
\__luamml_patch_package:n {amstext}
\__luamml_patch_package:n {amsmath}
\__luamml_patch_package:n {array}
%</luatex>

View File

@ -18,6 +18,13 @@
\begin{document}
\tagstructbegin{tag=Document}
\tagstructbegin{tag=P}
\tagmcbegin{tag=P}
hello
\tagmcend
\tagstructend
\LuaMMLTagAF{} {
\[
\begin{pmatrix}
@ -27,8 +34,8 @@
\end{pmatrix}
=
\begin{cases}
1 & $if $a=b\\
2 & $else$
1 & \text{if $a=b$} \\
2 & \text{else}
\end{cases}
\]
}