@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/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
|
-
|
|
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
|
-
|
|
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);
|