From d2b1d7e98a93c7209b5bf9ced982f1887a3e5dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20F=C3=A4rber?= <01mf02@gmail.com> Date: Mon, 20 Jan 2025 11:34:09 +0100 Subject: [PATCH] MathML output for accents. --- crates/typst-library/src/html/dom.rs | 2 ++ crates/typst-library/src/math/equation.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/typst-library/src/html/dom.rs b/crates/typst-library/src/html/dom.rs index a5159d47f..961a4ea74 100644 --- a/crates/typst-library/src/html/dom.rs +++ b/crates/typst-library/src/html/dom.rs @@ -480,6 +480,8 @@ pub mod tag { mfrac mi mmultiscripts + mo + mover mprescripts mrow msub diff --git a/crates/typst-library/src/math/equation.rs b/crates/typst-library/src/math/equation.rs index 7cef535bb..ed03454a7 100644 --- a/crates/typst-library/src/math/equation.rs +++ b/crates/typst-library/src/math/equation.rs @@ -165,7 +165,8 @@ impl Synthesize for Packed { } use crate::foundations::SequenceElem; -use crate::math::{AttachElem, FracElem, LrElem, PrimesElem}; +use crate::math::{AccentElem, AttachElem, FracElem, LrElem, PrimesElem}; +use ecow::eco_format; fn bla(elem: &Content, engine: &mut Engine, styles: StyleChain) -> SourceResult { dbg!(elem); if let Some(sequence) = elem.to_packed::() { @@ -186,6 +187,14 @@ fn bla(elem: &Content, engine: &mut Engine, styles: StyleChain) -> SourceResult< show_frac(elem, engine, styles) } else if let Some(elem) = elem.to_packed::() { show_attach(elem, engine, styles) + } else if let Some(elem) = elem.to_packed::() { + let accent = TextElem::packed(eco_format!(" {}", elem.accent.0)); + let accent = HtmlElem::new(tag::math::mo).with_body(Some(accent)).pack(); + let body = Content::sequence([elem.base.clone(), accent]); + Ok(HtmlElem::new(tag::math::mover) + .with_body(Some(body)) + .pack() + .spanned(elem.span())) } else { Ok(elem.clone()) }