@drghaliasri/butex 7.3.4 → 7.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document.d.mts +2 -0
- package/dist/document.d.ts +2 -0
- package/dist/document.js +35 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +35 -2
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +68 -5
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +2 -0
- package/dist/document2.d.ts +2 -0
- package/dist/document2.js +68 -5
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +68 -5
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.global.js +35 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +35 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +69 -5
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +69 -5
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.js +63 -4
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +63 -4
- package/dist/react-document2-preview.mjs.map +1 -1
- package/dist/react-document2.d.mts +2 -0
- package/dist/react-document2.d.ts +2 -0
- package/dist/react-document2.js +69 -5
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +69 -5
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +2 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.js +69 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +69 -5
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3586,6 +3586,31 @@ function formatDigits(value, digitForm = "western") {
|
|
|
3586
3586
|
}).join("");
|
|
3587
3587
|
}
|
|
3588
3588
|
|
|
3589
|
+
// src/editor/indexSequence.ts
|
|
3590
|
+
function isIndexComma(node) {
|
|
3591
|
+
return node.kind === "operator" && (node.expr === "," || node.expr === "\u060C");
|
|
3592
|
+
}
|
|
3593
|
+
function isValidIndexSequence(chain) {
|
|
3594
|
+
let count = 0;
|
|
3595
|
+
let afterComma = false;
|
|
3596
|
+
for (const node of chain.nodes) {
|
|
3597
|
+
if (node.superscript || node.subscript) return false;
|
|
3598
|
+
if (isIndexComma(node)) {
|
|
3599
|
+
if (count === 0 || afterComma) return false;
|
|
3600
|
+
afterComma = true;
|
|
3601
|
+
continue;
|
|
3602
|
+
}
|
|
3603
|
+
const isDigit = node.kind === "number" && /^[0-9]$/.test(node.expr);
|
|
3604
|
+
const identity = node.sourceLatex ?? node.expr;
|
|
3605
|
+
const isLetter = node.kind === "char" && (/^[A-Za-z]$/.test(identity) || Array.from(identity).length === 1 && /^\p{L}$/u.test(identity));
|
|
3606
|
+
if (!isDigit && !isLetter) return false;
|
|
3607
|
+
count += 1;
|
|
3608
|
+
afterComma = false;
|
|
3609
|
+
if (count > 64) return false;
|
|
3610
|
+
}
|
|
3611
|
+
return count >= 2 && !afterComma;
|
|
3612
|
+
}
|
|
3613
|
+
|
|
3589
3614
|
// src/editor/render.ts
|
|
3590
3615
|
function selectedDigitForm(options) {
|
|
3591
3616
|
return options?.digitForm ?? "western";
|
|
@@ -3812,10 +3837,18 @@ function renderNodeArabic(node, options) {
|
|
|
3812
3837
|
return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
|
|
3813
3838
|
}
|
|
3814
3839
|
function renderChainEnglish(chain, options) {
|
|
3840
|
+
if (chain.indexSequence && isValidIndexSequence(chain)) {
|
|
3841
|
+
const atoms = chain.nodes.map((node) => isIndexComma(node) ? "," : renderNodeEnglish(node, options));
|
|
3842
|
+
return "\\mathnormal{" + atoms.join("") + "}";
|
|
3843
|
+
}
|
|
3815
3844
|
return chain.nodes.map((node) => renderNodeEnglish(node, options)).join(" ");
|
|
3816
3845
|
}
|
|
3817
3846
|
function renderChainArabic(chain, options) {
|
|
3818
|
-
|
|
3847
|
+
const rendered = chain.nodes.slice().reverse().map((node) => renderNodeArabic(node, options));
|
|
3848
|
+
if (chain.indexSequence && isValidIndexSequence(chain)) {
|
|
3849
|
+
return "\\mathnormal{" + rendered.join("\\,") + "}";
|
|
3850
|
+
}
|
|
3851
|
+
return rendered.join(" ");
|
|
3819
3852
|
}
|
|
3820
3853
|
function renderEnglishLatexFromSession(session) {
|
|
3821
3854
|
return renderChainEnglish(session.englishTree, { digitForm: session.currentDigitForm ?? "western" });
|
|
@@ -5273,6 +5306,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5273
5306
|
if (!engLocated) {
|
|
5274
5307
|
return false;
|
|
5275
5308
|
}
|
|
5309
|
+
if (engLocated.chain.indexSequence) return false;
|
|
5276
5310
|
const nodes = engLocated.chain.nodes;
|
|
5277
5311
|
const i = session.caret.index;
|
|
5278
5312
|
let targetId = null;
|