MathML
HTML, SVG と並ぶ、数学的表記を記述するためのマークアップ言語。
Igalia のお陰で MathML は Baseline 2023 で Newly available 扱いとなり、ブラウザの実装も出揃ってきた。 とはいえまだ各ブラウザごとにレンダリングの差異が存在する。
DOM 上の扱い
現状全ての MathML 要素は MathMLElement として表現されている。各要素ごとのインターフェイスは存在しない。
React JSX で扱う
React で MathML を扱うことができるが @types/react にまだ型定義がない。
とりあえず今すぐ雑に使いたい場合は、コンポーネントに以下のように型定義を追加すればいい。
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>;
}
}
}