@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.
Files changed (44) hide show
  1. package/README.md +2 -0
  2. package/dist/document.d.mts +2 -0
  3. package/dist/document.d.ts +2 -0
  4. package/dist/document.js +36 -3
  5. package/dist/document.js.map +1 -1
  6. package/dist/document.mjs +36 -3
  7. package/dist/document.mjs.map +1 -1
  8. package/dist/document2-cli.js +70 -7
  9. package/dist/document2-cli.js.map +1 -1
  10. package/dist/document2.d.mts +2 -0
  11. package/dist/document2.d.ts +2 -0
  12. package/dist/document2.js +70 -7
  13. package/dist/document2.js.map +1 -1
  14. package/dist/document2.mjs +70 -7
  15. package/dist/document2.mjs.map +1 -1
  16. package/dist/index.d.mts +2 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.global.js +36 -2
  19. package/dist/index.global.js.map +1 -1
  20. package/dist/index.js +36 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +36 -2
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/react-document.js +71 -7
  25. package/dist/react-document.js.map +1 -1
  26. package/dist/react-document.mjs +71 -7
  27. package/dist/react-document.mjs.map +1 -1
  28. package/dist/react-document2-preview.js +65 -6
  29. package/dist/react-document2-preview.js.map +1 -1
  30. package/dist/react-document2-preview.mjs +65 -6
  31. package/dist/react-document2-preview.mjs.map +1 -1
  32. package/dist/react-document2.d.mts +2 -0
  33. package/dist/react-document2.d.ts +2 -0
  34. package/dist/react-document2.js +71 -7
  35. package/dist/react-document2.js.map +1 -1
  36. package/dist/react-document2.mjs +71 -7
  37. package/dist/react-document2.mjs.map +1 -1
  38. package/dist/react.d.mts +2 -0
  39. package/dist/react.d.ts +2 -0
  40. package/dist/react.js +71 -7
  41. package/dist/react.js.map +1 -1
  42. package/dist/react.mjs +71 -7
  43. package/dist/react.mjs.map +1 -1
  44. 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";
@@ -3693,7 +3718,7 @@ function renderCharContent(node, options) {
3693
3718
  }
3694
3719
  function renderNodeEnglish(node, options) {
3695
3720
  if (node.kind === "delimiter" && node.innerExpr) {
3696
- return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
3721
+ return `${node.leftDelimExpr} ${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
3697
3722
  }
3698
3723
  if (node.kind === "boxed" && node.innerExpr) {
3699
3724
  const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
@@ -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
- return chain.nodes.slice().reverse().map((node) => renderNodeArabic(node, options)).join(" ");
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;