@drghaliasri/butex 7.3.4 → 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.
Files changed (43) hide show
  1. package/dist/document.d.mts +2 -0
  2. package/dist/document.d.ts +2 -0
  3. package/dist/document.js +35 -2
  4. package/dist/document.js.map +1 -1
  5. package/dist/document.mjs +35 -2
  6. package/dist/document.mjs.map +1 -1
  7. package/dist/document2-cli.js +68 -5
  8. package/dist/document2-cli.js.map +1 -1
  9. package/dist/document2.d.mts +2 -0
  10. package/dist/document2.d.ts +2 -0
  11. package/dist/document2.js +68 -5
  12. package/dist/document2.js.map +1 -1
  13. package/dist/document2.mjs +68 -5
  14. package/dist/document2.mjs.map +1 -1
  15. package/dist/index.d.mts +2 -0
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.global.js +35 -1
  18. package/dist/index.global.js.map +1 -1
  19. package/dist/index.js +35 -1
  20. package/dist/index.js.map +1 -1
  21. package/dist/index.mjs +35 -1
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/react-document.js +69 -5
  24. package/dist/react-document.js.map +1 -1
  25. package/dist/react-document.mjs +69 -5
  26. package/dist/react-document.mjs.map +1 -1
  27. package/dist/react-document2-preview.js +63 -4
  28. package/dist/react-document2-preview.js.map +1 -1
  29. package/dist/react-document2-preview.mjs +63 -4
  30. package/dist/react-document2-preview.mjs.map +1 -1
  31. package/dist/react-document2.d.mts +2 -0
  32. package/dist/react-document2.d.ts +2 -0
  33. package/dist/react-document2.js +69 -5
  34. package/dist/react-document2.js.map +1 -1
  35. package/dist/react-document2.mjs +69 -5
  36. package/dist/react-document2.mjs.map +1 -1
  37. package/dist/react.d.mts +2 -0
  38. package/dist/react.d.ts +2 -0
  39. package/dist/react.js +69 -5
  40. package/dist/react.js.map +1 -1
  41. package/dist/react.mjs +69 -5
  42. package/dist/react.mjs.map +1 -1
  43. 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;
@@ -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";
@@ -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
- return chain.nodes.slice().reverse().map((node) => renderNodeArabic(node, options)).join(" ");
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;