@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.js
CHANGED
|
@@ -3628,6 +3628,31 @@ function formatDigits(value, digitForm = "western") {
|
|
|
3628
3628
|
}).join("");
|
|
3629
3629
|
}
|
|
3630
3630
|
|
|
3631
|
+
// src/editor/indexSequence.ts
|
|
3632
|
+
function isIndexComma(node) {
|
|
3633
|
+
return node.kind === "operator" && (node.expr === "," || node.expr === "\u060C");
|
|
3634
|
+
}
|
|
3635
|
+
function isValidIndexSequence(chain) {
|
|
3636
|
+
let count = 0;
|
|
3637
|
+
let afterComma = false;
|
|
3638
|
+
for (const node of chain.nodes) {
|
|
3639
|
+
if (node.superscript || node.subscript) return false;
|
|
3640
|
+
if (isIndexComma(node)) {
|
|
3641
|
+
if (count === 0 || afterComma) return false;
|
|
3642
|
+
afterComma = true;
|
|
3643
|
+
continue;
|
|
3644
|
+
}
|
|
3645
|
+
const isDigit = node.kind === "number" && /^[0-9]$/.test(node.expr);
|
|
3646
|
+
const identity = node.sourceLatex ?? node.expr;
|
|
3647
|
+
const isLetter = node.kind === "char" && (/^[A-Za-z]$/.test(identity) || Array.from(identity).length === 1 && /^\p{L}$/u.test(identity));
|
|
3648
|
+
if (!isDigit && !isLetter) return false;
|
|
3649
|
+
count += 1;
|
|
3650
|
+
afterComma = false;
|
|
3651
|
+
if (count > 64) return false;
|
|
3652
|
+
}
|
|
3653
|
+
return count >= 2 && !afterComma;
|
|
3654
|
+
}
|
|
3655
|
+
|
|
3631
3656
|
// src/editor/render.ts
|
|
3632
3657
|
function selectedDigitForm(options) {
|
|
3633
3658
|
return options?.digitForm ?? "western";
|
|
@@ -3854,10 +3879,18 @@ function renderNodeArabic(node, options) {
|
|
|
3854
3879
|
return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
|
|
3855
3880
|
}
|
|
3856
3881
|
function renderChainEnglish(chain, options) {
|
|
3882
|
+
if (chain.indexSequence && isValidIndexSequence(chain)) {
|
|
3883
|
+
const atoms = chain.nodes.map((node) => isIndexComma(node) ? "," : renderNodeEnglish(node, options));
|
|
3884
|
+
return "\\mathnormal{" + atoms.join("") + "}";
|
|
3885
|
+
}
|
|
3857
3886
|
return chain.nodes.map((node) => renderNodeEnglish(node, options)).join(" ");
|
|
3858
3887
|
}
|
|
3859
3888
|
function renderChainArabic(chain, options) {
|
|
3860
|
-
|
|
3889
|
+
const rendered = chain.nodes.slice().reverse().map((node) => renderNodeArabic(node, options));
|
|
3890
|
+
if (chain.indexSequence && isValidIndexSequence(chain)) {
|
|
3891
|
+
return "\\mathnormal{" + rendered.join("\\,") + "}";
|
|
3892
|
+
}
|
|
3893
|
+
return rendered.join(" ");
|
|
3861
3894
|
}
|
|
3862
3895
|
function renderEnglishLatexFromSession(session) {
|
|
3863
3896
|
return renderChainEnglish(session.englishTree, { digitForm: session.currentDigitForm ?? "western" });
|
|
@@ -5315,6 +5348,7 @@ function tryMergeLeafTyping(session, kind, fragment) {
|
|
|
5315
5348
|
if (!engLocated) {
|
|
5316
5349
|
return false;
|
|
5317
5350
|
}
|
|
5351
|
+
if (engLocated.chain.indexSequence) return false;
|
|
5318
5352
|
const nodes = engLocated.chain.nodes;
|
|
5319
5353
|
const i = session.caret.index;
|
|
5320
5354
|
let targetId = null;
|