Cancelled terms for MathML.

This commit is contained in:
Michael Färber 2025-01-20 11:56:02 +01:00
parent d2b1d7e98a
commit 1cbc4680d6
2 changed files with 14 additions and 1 deletions

View File

@ -477,6 +477,7 @@ pub mod tag {
tags! {
math
menclose
mfrac
mi
mmultiscripts

View File

@ -165,7 +165,7 @@ impl Synthesize for Packed<EquationElem> {
}
use crate::foundations::SequenceElem;
use crate::math::{AccentElem, AttachElem, FracElem, LrElem, PrimesElem};
use crate::math::{AccentElem, AttachElem, CancelElem, FracElem, LrElem, PrimesElem};
use ecow::eco_format;
fn bla(elem: &Content, engine: &mut Engine, styles: StyleChain) -> SourceResult<Content> {
dbg!(elem);
@ -187,6 +187,18 @@ fn bla(elem: &Content, engine: &mut Engine, styles: StyleChain) -> SourceResult<
show_frac(elem, engine, styles)
} else if let Some(elem) = elem.to_packed::<AttachElem>() {
show_attach(elem, engine, styles)
} else if let Some(elem) = elem.to_packed::<CancelElem>() {
let notation = if elem.cross(styles) {
"updiagonalstrike downdiagonalstrike"
} else if elem.inverted(styles) {
"downdiagonalstrike"
} else {
"updiagonalstrike"
};
let tag = HtmlElem::new(tag::math::menclose)
.with_attr(HtmlAttr::constant("notation"), notation);
let body = elem.body.clone();
Ok(tag.with_body(Some(body)).pack().spanned(elem.span()))
} else if let Some(elem) = elem.to_packed::<AccentElem>() {
let accent = TextElem::packed(eco_format!(" {}", elem.accent.0));
let accent = HtmlElem::new(tag::math::mo).with_body(Some(accent)).pack();