MathML
HTML, SVG と並ぶ、数学的表記を記述するためのマークアップ言語。
Igalia のお陰で MathML は Baseline 2023 で Newly available 扱いとなり、ブラウザの実装も出揃ってきた。
https://www.igalia.com/2024/12/17/MathML-2024.html
とはいえまだ各ブラウザごとにレンダリングの差異が存在する。
https://note.com/takamumath/n/n32ebfd982782
DOM 上の扱い
現状全ての MathML 要素は MathMLElement として表現されている。各要素ごとのインターフェイスは存在しない。
https://developer.mozilla.org/ja/docs/Web/API/MathMLElement
React JSX で扱う
React で MathML を扱うことができるが @types/react にまだ型定義がない。
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/71187
とりあえず今すぐ雑に使いたい場合は、コンポーネントに以下のように型定義を追加すればいい。
code: ts
declare module "react" {
namespace JSX {
interface IntrinsicElements {
math: React.DetailedHTMLProps<HTMLAttributes<MathMLElement>, MathMLElement>;
mrow: React.DetailedHTMLProps<HTMLAttributes<MathMLElement>, MathMLElement>;
mi: React.DetailedHTMLProps<HTMLAttributes<MathMLElement>, MathMLElement>;
mn: React.DetailedHTMLProps<HTMLAttributes<MathMLElement>, MathMLElement>;
mo: React.DetailedHTMLProps<HTMLAttributes<MathMLElement>, MathMLElement>;
msup: React.DetailedHTMLProps<HTMLAttributes<MathMLElement>, MathMLElement>;
}
}
}