Skip to content

feat(markup): 既定 OFF の数式表示を通常画面と埋め込みに追加 - #336

Draft
tamaina wants to merge 2 commits into
developfrom
feat/juice-safe-formula
Draft

tamaina wants to merge 2 commits into
developfrom
feat/juice-safe-formula

Conversation

@tamaina

@tamaina tamaina commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

What

MFM のインライン/ブロック数式を KaTeX で表示します。既定は OFF。管理画面のブランディング設定で明示的に有効にした場合だけ、通常画面・埋め込みの共有コンポーネントを遅延読み込みします。

既存の clientOptions に追加する latexEnabled と管理者限定 admin/update-meta を使用し、新しい API・DB migration は追加しません。設定がない/不正/無効、または Formula を提供しない renderer は従来の code 表示を維持します。新しい文言は VVI のローカル ja-JP / en-US 辞書です。

Why

Refs #298, #260。Issue が参照する JUICE の数式実装 を、9k の共有 renderer と既存の設定経路に適合させる小スライスです。#331 / #333 の別機能は含みません。

Additional info (optional)

  • KaTeX 0.19.1、trust:false、strict、maxSize 20、maxExpand 1000、数式ごとに独立した macros。
  • JUICE と同じ入力長 1000・波括弧深さ 3 の制限。生成 HTML も 100,000 文字までとし、不正入力・過剰な入力・読み込み失敗はエスケープ済みの code/pre に戻します。JUICE との差として throwOnError:true を指定し、パースエラーの表示をこのフォールバックに統一しています。
  • inline と displayMode の block を区別し、MathML を保持。無効時と事前に過剰と判定した入力では KaTeX の chunk を読み込みません。
  • 埋め込みを含む別画面への設定反映は既存の metadata 再読込タイミングです。読み込み失敗後の再試行はページ再読込で行います。
  • 過去の VVI golden の source hash / offset は変更せず、今回の正確な差分だけを復元する検証を追加しました。feat(markup): ネコ文字置換を閲覧者の設定で無効にする #331 も MkMfm/shared renderer を変更するため、統合時は双方の挙動と復元証明を再確認してください。

検証(最終 head 16b70de8ad101e5adbd6acebec967421ff67a18c):

  • CI: 32 成功・1 スキップ、待機中・失敗なし。frontend unit 102 ファイル・1,374 テスト成功。main / embed の型検査・本番ビルド、frozen-lockfile install、lint、E2E、SPDX も成功。
  • feature frontend CI で既存 browser fixture と新しい formula fixture が成功。Chromium 156 で実 MkMfm / EmMfm / Branding / 設定部品の表示、保存要求・再読込、OFF、危険なコマンド、遅延 chunk 失敗、複雑さ制限を確認。
  • ローカル: 数式・metadata 契約 26 テスト、関連 renderer / locale 証明 / 起動 10 ファイル・423 テスト、embed 型検査・ビルド、変更 lint / SPDX / locale safety 成功。開発機 Chrome 157 でも formula fixture 成功。
  • ブラウザ fixture の API と保存領域は mock で、実サービスの管理設定は変更していません。
  • 開発機では共通ロックで重い検証を直列化し、終了後に自分の隔離依存・生成物を削除。マージ・デプロイなし。

CHANGELOG 候補: 管理者が有効にした場合に、通常画面と埋め込みで MFM の数式を安全に表示できるようにしました。

Checklist

@github-actions

Copy link
Copy Markdown
Contributor

🖥 Frontend Diagnostics Report

Metric @ Base @ Head Δ MAD
Requests 287
± 0
291
± 0
$\color{orange}{\text{+4}}$
$\color{orange}{\text{+1.4\%}}$
0

Only metrics showing significant changes are displayed.

View details

Requests by resource type
Type Requests Encoded bytes
Base Head Δ Base Head Δ
Document 2 2 0 37 KB 37 KB 0 B
Script 179 183 $\color{orange}{\text{+4}}$ 3.3 MB 3.3 MB $\color{orange}{\text{+5.4 KB}}$
Stylesheet 62 62 0 283 KB 283 KB 0 B
Fetch 23 23 0 76 KB 76 KB 0 B
Image 10 10 0 70 KB 70 KB 0 B
Font 2 2 0 119 KB 119 KB 0 B
Other 9 9 0 173 KB 173 KB $\color{orange}{\text{+2 B}}$
V8 heap snapshot statistics
Metric @ Base @ Head Δ MAD
$\color{gray}{\rule{8pt}{8pt}}$ Total 14 MB
± 22 KB
14 MB
± 1.7 KB
$\text{+5 KB}$
$\text{+0\%}$
22 KB
$\color{orange}{\rule{8pt}{8pt}}$ Code 3.3 MB 3.3 MB $\text{+324 B}$ 735 B
$\color{red}{\rule{8pt}{8pt}}$ Strings 1.6 MB 1.6 MB $\text{+900 B}$ 228 B
$\color{cyan}{\rule{8pt}{8pt}}$ JS arrays 130 KB 130 KB $\text{-92 B}$ 92 B
$\color{green}{\rule{8pt}{8pt}}$ Typed arrays 0 B 0 B 0 B 0 B
$\color{yellow}{\rule{8pt}{8pt}}$ System objects 0 B 0 B 0 B 0 B
$\color{violet}{\rule{8pt}{8pt}}$ Other JS objs 2.5 MB 2.5 MB $\text{+2.9 KB}$ 16 B
$\color{pink}{\rule{8pt}{8pt}}$ Other non-JS objs 6 MB 6 MB $\text{-4.1 KB}$ 17 KB

Download representative heap snapshot: base / head

📦 Bundle Stats

Chunk size diff (44 updated, 1 added, 0 removed)
Chunk Base Head Δ Δ (%)
(total) 17 MB 17 MB $\color{orange}{\text{+276 KB}}$ $\color{orange}{\text{+1.6\%}}$
../features/markup/frontend/shared/MkFormulaCore.vue scripts/hvhWu9yWI-CmEusvA2.js
0 B 260 KB $\color{orange}{\text{+260 KB}}$ $\color{orange}{\text{( + )}}$
../features/instance/frontend/pages/admin/branding.vue scripts/hvhWu9yWI-D4UPR8X6.js → scripts/hvhWu9yWI-DaQzNDtY.js
10 KB 11 KB $\color{orange}{\text{+1.2 KB}}$ $\color{orange}{\text{+11.3\%}}$
virtual:vite-vue-internationalization/locale/th-TH scripts/hvhWu9yWI-BP7v1nJV.js → scripts/hvhWu9yWI-DxqpJYia.js
415 KB 415 KB $\text{+310 B}$ $\text{+0.1\%}$
virtual:vite-vue-internationalization/locale/ru-RU scripts/hvhWu9yWI-KNaa4uSL.js → scripts/hvhWu9yWI-DRIc3xPM.js
308 KB 309 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/uk-UA scripts/hvhWu9yWI-C79B1YQj.js → scripts/hvhWu9yWI-BgLu4VJ-.js
302 KB 302 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/bn-BD scripts/hvhWu9yWI-Cj2mgrAP.js → scripts/hvhWu9yWI-Cj7PLcae.js
275 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/lo-LA scripts/hvhWu9yWI-BwomrIvX.js → scripts/hvhWu9yWI-BZZMOu7x.js
275 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/si-LK scripts/hvhWu9yWI-qQdH6cfc.js → scripts/hvhWu9yWI-Buj8WRQI.js
275 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/el-GR scripts/hvhWu9yWI-DE7qTMp-.js → scripts/hvhWu9yWI-BTI9823p.js
275 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/fa-IR scripts/hvhWu9yWI-B1HjKqTB.js → scripts/hvhWu9yWI-CaV1mLq3.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/jbo-EN scripts/hvhWu9yWI-kpmoOEsj.js → scripts/hvhWu9yWI-3ye6Z0jJ.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ja-JP scripts/hvhWu9yWI-BRMrOS5C.js → scripts/hvhWu9yWI-Caq1gqwN.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ro-RO scripts/hvhWu9yWI-CM0VtpnU.js → scripts/hvhWu9yWI-BL2DsFih.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/tl-PH scripts/hvhWu9yWI-CSywSayp.js → scripts/hvhWu9yWI-CMQrJfdh.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ko-GS scripts/hvhWu9yWI-tq2SuTQb.js → scripts/hvhWu9yWI-CL7omMo0.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/hu-HU scripts/hvhWu9yWI-DkA5f3z_.js → scripts/hvhWu9yWI-ZtTfcXR4.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/uz-UZ scripts/hvhWu9yWI-DPIHeE02.js → scripts/hvhWu9yWI-k8sv9gZZ.js
274 KB 275 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/sv-SE scripts/hvhWu9yWI-DLSTrj7G.js → scripts/hvhWu9yWI-wGQ4hnNW.js
274 KB 274 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/hr-HR scripts/hvhWu9yWI-DKcx3E1w.js → scripts/hvhWu9yWI-BKDVKzeo.js
274 KB 274 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ht-HT scripts/hvhWu9yWI-Cfs7MjuF.js → scripts/hvhWu9yWI-ohqLFCoK.js
274 KB 274 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ja-KS scripts/hvhWu9yWI-9kwnlZQz.js → scripts/hvhWu9yWI-ikETil5z.js
272 KB 273 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/de-DE scripts/hvhWu9yWI-DjBUJ0nS.js → scripts/hvhWu9yWI-C3VnfAiH.js
255 KB 255 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ko-KR scripts/hvhWu9yWI-DHQYiQrV.js → scripts/hvhWu9yWI-Ci4W0uSU.js
255 KB 255 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ar-SA scripts/hvhWu9yWI-Byi38SYr.js → scripts/hvhWu9yWI-CnegcSxh.js
252 KB 252 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/ca-ES scripts/hvhWu9yWI-Dof1MPjG.js → scripts/hvhWu9yWI-COh0y6c1.js
252 KB 252 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/vi-VN scripts/hvhWu9yWI-BrRbMNh3.js → scripts/hvhWu9yWI-CEmg7b1a.js
251 KB 252 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/es-ES scripts/hvhWu9yWI-BzGavqdS.js → scripts/hvhWu9yWI-DmIa9pCf.js
250 KB 251 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/fr-FR scripts/hvhWu9yWI-Ul_Uwn4A.js → scripts/hvhWu9yWI-CaIPjwvA.js
250 KB 250 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/tr-TR scripts/hvhWu9yWI-CsvW6-0P.js → scripts/hvhWu9yWI-BPjUR5wn.js
249 KB 249 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
virtual:vite-vue-internationalization/locale/it-IT scripts/hvhWu9yWI-B8r2XkNY.js → scripts/hvhWu9yWI-DP7Ng-Md.js
247 KB 248 KB $\text{+310 B}$ $\color{orange}{\text{+0.1\%}}$
(other generated chunks) 2.5 MB 2.5 MB $\color{orange}{\text{+1.5 KB}}$ $\text{+0.1\%}$
(other) 3.3 MB 3.3 MB $\color{orange}{\text{+4.4 KB}}$ $\color{orange}{\text{+0.1\%}}$
Startup chunk size (1 updated, 0 added, 0 removed)
Chunk Base Head Δ Δ (%)
(total) 127 KB 127 KB $\text{+76 B}$ $\text{+0.1\%}$
src/_boot_.ts scripts/hvhWu9yWI-DsE7HXeh.js → scripts/hvhWu9yWI-CZBAAo1l.js
5.3 KB 5.4 KB $\text{+76 B}$ $\color{orange}{\text{+1.4\%}}$
(other generated chunks) 122 KB 122 KB 0 B 0%

Startup chunks are the Vite entry for src/_boot_.ts and its static imports.

Bundles Modules Entries Imports Size
Static Dynamic Rendered Gzip Brotli
Base 538 3,209 24 10,848 389 23 MB 6.2 MB 5 MB
Head 541 3,221 24 10,872 390 24 MB 6.3 MB 5.1 MB
Δ $\color{orange}{\text{+3}}$ $\color{orange}{\text{+12}}$ 0 $\color{orange}{\text{+24}}$ $\color{orange}{\text{+1}}$ $\color{orange}{\text{+483 KB}}$ $\color{orange}{\text{+104 KB}}$ $\color{orange}{\text{+82 KB}}$
Δ (%) $\color{orange}{\text{+0.6\%}}$ $\color{orange}{\text{+0.4\%}}$ 0% $\color{orange}{\text{+0.2\%}}$ $\color{orange}{\text{+0.3\%}}$ $\color{orange}{\text{+2.1\%}}$ $\color{orange}{\text{+1.7\%}}$ $\color{orange}{\text{+1.6\%}}$

Open treemap HTML

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant