diff --git a/src/lib/MathText.tsx b/src/lib/MathText.tsx
index 2eaed7d..049634d 100644
--- a/src/lib/MathText.tsx
+++ b/src/lib/MathText.tsx
@@ -41,7 +41,43 @@ const FORMULA = /[=<>≤≥≠∈∉⊂⊆∪∩+×÷^√∑∫]|[0-9۰-۹A-Za-z
* چشم وسطِ فرمول به خطِ بعد نیفتد. عددِ تنها و عبارتِ کوتاهِ بدونِ نمادِ عمل داخلِ جمله میماند.
* آزموده نشده: صفحهی واقعیِ اپ در Chrome و Safari؛ فقط منطقِ تشخیص با نمونههای بانک سنجیده شد.
*/
+// ماتریس «[[۲، ۷]، [۴، ۱]]»: ردیفها داخلِ کروشهی تو در تو. اگر مثلِ متنِ عادی بگذاریم، در خطِ باریک
+// وسطِ ردیف شکسته میشود و راستبهچپ بودنِ جمله عددها را جابهجا نشان میدهد (گزارشِ مالک ۲۰۲۶-۱۰-۱۴).
+const MATRIX = /\[\s*\[[^\[\]]*\](?:\s*[،,]\s*\[[^\[\]]*\])*\s*\]/g;
+
+function Matrix({ src }: { src: string }) {
+ const rows = [...src.matchAll(/\[([^\[\]]*)\]/g)].map((m) => m[1].split(/[،,]/).map((c) => plainPersian(plainMath(c.trim()))));
+ const border = '2px solid currentColor';
+ return (
+
+ {rows.map((row, i) => (
+
+ {row.map((c, j) => {c})}
+
+ ))}
+
+ );
+}
+
export function MathText({ text: raw, display = false }: { text: string; display?: boolean }) {
+ if (!MATRIX.test(raw)) { MATRIX.lastIndex = 0; return ; }
+ MATRIX.lastIndex = 0;
+ const out: React.ReactNode[] = [];
+ let last = 0, k = 0;
+ for (const m of raw.matchAll(MATRIX)) {
+ const at = m.index ?? 0;
+ if (at > last) out.push();
+ out.push();
+ last = at + m[0].length;
+ }
+ if (last < raw.length) out.push();
+ return <>{out}>;
+}
+
+function Inline({ raw, display }: { raw: string; display: boolean }) {
const text = plainPersian(plainMath(raw));
const out: React.ReactNode[] = [];
const depth = bracketDepth(text);