@drghaliasri/butex 7.3.3 → 7.3.5
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/README.md +2 -0
- package/dist/document.d.mts +2 -0
- package/dist/document.d.ts +2 -0
- package/dist/document.js +36 -3
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +36 -3
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +70 -7
- 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 +70 -7
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +70 -7
- 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 +36 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +71 -7
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +71 -7
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.js +65 -6
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +65 -6
- 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 +71 -7
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +71 -7
- 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 +71 -7
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +71 -7
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -109,6 +109,8 @@ type EditorSyncState = 'synced' | 'diverged';
|
|
|
109
109
|
type EditorChain = {
|
|
110
110
|
id: string;
|
|
111
111
|
nodes: EditorNode[];
|
|
112
|
+
/** Complete script authored as \\mathnormal{ordered,index,atoms}. */
|
|
113
|
+
indexSequence?: boolean;
|
|
112
114
|
};
|
|
113
115
|
type EditorNode = {
|
|
114
116
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -109,6 +109,8 @@ type EditorSyncState = 'synced' | 'diverged';
|
|
|
109
109
|
type EditorChain = {
|
|
110
110
|
id: string;
|
|
111
111
|
nodes: EditorNode[];
|
|
112
|
+
/** Complete script authored as \\mathnormal{ordered,index,atoms}. */
|
|
113
|
+
indexSequence?: boolean;
|
|
112
114
|
};
|
|
113
115
|
type EditorNode = {
|
|
114
116
|
id: string;
|
package/dist/index.global.js
CHANGED
|
@@ -3628,6 +3628,31 @@ ${STANDARD_COMMAND_CSS}
|
|
|
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";
|
|
@@ -3735,7 +3760,7 @@ ${STANDARD_COMMAND_CSS}
|
|
|
3735
3760
|
}
|
|
3736
3761
|
function renderNodeEnglish(node, options) {
|
|
3737
3762
|
if (node.kind === "delimiter" && node.innerExpr) {
|
|
3738
|
-
return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
|
|
3763
|
+
return `${node.leftDelimExpr} ${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
|
|
3739
3764
|
}
|
|
3740
3765
|
if (node.kind === "boxed" && node.innerExpr) {
|
|
3741
3766
|
const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
|
|
@@ -3854,10 +3879,18 @@ ${STANDARD_COMMAND_CSS}
|
|
|
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 @@ ${STANDARD_COMMAND_CSS}
|
|
|
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;
|