@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/document.mjs CHANGED
@@ -134,7 +134,7 @@ var DelimiterNode = class extends BaseAstNode {
134
134
  this.rightDelimExpr = rightDelimExpr2;
135
135
  }
136
136
  latex() {
137
- return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
137
+ return this.leftDelimExpr + " " + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
138
138
  }
139
139
  arabicLatex() {
140
140
  const sup = this.superscript !== null ? this.superscript.arabicLatex() : "";
@@ -1988,6 +1988,31 @@ function formatDigits(value, digitForm = "western") {
1988
1988
  }).join("");
1989
1989
  }
1990
1990
 
1991
+ // src/editor/indexSequence.ts
1992
+ function isIndexComma(node) {
1993
+ return node.kind === "operator" && (node.expr === "," || node.expr === "\u060C");
1994
+ }
1995
+ function isValidIndexSequence(chain) {
1996
+ let count = 0;
1997
+ let afterComma = false;
1998
+ for (const node of chain.nodes) {
1999
+ if (node.superscript || node.subscript) return false;
2000
+ if (isIndexComma(node)) {
2001
+ if (count === 0 || afterComma) return false;
2002
+ afterComma = true;
2003
+ continue;
2004
+ }
2005
+ const isDigit = node.kind === "number" && /^[0-9]$/.test(node.expr);
2006
+ const identity = node.sourceLatex ?? node.expr;
2007
+ const isLetter = node.kind === "char" && (/^[A-Za-z]$/.test(identity) || Array.from(identity).length === 1 && /^\p{L}$/u.test(identity));
2008
+ if (!isDigit && !isLetter) return false;
2009
+ count += 1;
2010
+ afterComma = false;
2011
+ if (count > 64) return false;
2012
+ }
2013
+ return count >= 2 && !afterComma;
2014
+ }
2015
+
1991
2016
  // src/editor/render.ts
1992
2017
  function selectedDigitForm(options) {
1993
2018
  return options?.digitForm ?? "western";
@@ -2115,7 +2140,11 @@ function renderNodeArabic(node, options) {
2115
2140
  return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
2116
2141
  }
2117
2142
  function renderChainArabic(chain, options) {
2118
- return chain.nodes.slice().reverse().map((node) => renderNodeArabic(node, options)).join(" ");
2143
+ const rendered = chain.nodes.slice().reverse().map((node) => renderNodeArabic(node, options));
2144
+ if (chain.indexSequence && isValidIndexSequence(chain)) {
2145
+ return "\\mathnormal{" + rendered.join("") + "}";
2146
+ }
2147
+ return rendered.join(" ");
2119
2148
  }
2120
2149
  function renderArabicLatexFromSession(session) {
2121
2150
  return renderChainArabic(session.arabicTree, { digitForm: session.currentDigitForm ?? "western" });
@@ -3094,7 +3123,11 @@ function editorChainToAstChain(chain) {
3094
3123
  }
3095
3124
  nodes.push(converted.node);
3096
3125
  }
3097
- return { ok: true, chain: new ChainNode(nodes) };
3126
+ const content = new ChainNode(nodes);
3127
+ if (chain.indexSequence && isValidIndexSequence(chain)) {
3128
+ return { ok: true, chain: new ChainNode([new CommandNode("\\mathnormal", [], [content])]) };
3129
+ }
3130
+ return { ok: true, chain: content };
3098
3131
  }
3099
3132
  function mathNodeFromEditorSession(session, mathMode = "$", closing = "$") {
3100
3133
  const converted = editorChainToAstChain(session.englishTree);