@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/README.md
CHANGED
|
@@ -144,6 +144,8 @@ floating major tag, so CDN updates cannot change rendering behavior silently.
|
|
|
144
144
|
|
|
145
145
|
### 2) GUI editor contract (shippable editor UX)
|
|
146
146
|
|
|
147
|
+
When exporting a structured delimiter to English LaTeX, BuTeX places an ordinary space after its opening delimiter. In math mode this is a harmless token separator that keeps command-style delimiters such as `\left\lVert x\right\rVert` valid.
|
|
148
|
+
|
|
147
149
|
Use this when you want the same editor UX as the demo:
|
|
148
150
|
|
|
149
151
|
- Inject editor styles once via `injectBuTeXEditorStyles(document)` (or embed `BUTEX_EDITOR_CSS`).
|
package/dist/document.d.mts
CHANGED
|
@@ -173,6 +173,8 @@ type EditorSyncState = 'synced' | 'diverged';
|
|
|
173
173
|
type EditorChain = {
|
|
174
174
|
id: string;
|
|
175
175
|
nodes: EditorNode[];
|
|
176
|
+
/** Complete script authored as \\mathnormal{ordered,index,atoms}. */
|
|
177
|
+
indexSequence?: boolean;
|
|
176
178
|
};
|
|
177
179
|
type EditorNode = {
|
|
178
180
|
id: string;
|
package/dist/document.d.ts
CHANGED
|
@@ -173,6 +173,8 @@ type EditorSyncState = 'synced' | 'diverged';
|
|
|
173
173
|
type EditorChain = {
|
|
174
174
|
id: string;
|
|
175
175
|
nodes: EditorNode[];
|
|
176
|
+
/** Complete script authored as \\mathnormal{ordered,index,atoms}. */
|
|
177
|
+
indexSequence?: boolean;
|
|
176
178
|
};
|
|
177
179
|
type EditorNode = {
|
|
178
180
|
id: string;
|
package/dist/document.js
CHANGED
|
@@ -198,7 +198,7 @@ var DelimiterNode = class extends BaseAstNode {
|
|
|
198
198
|
this.rightDelimExpr = rightDelimExpr2;
|
|
199
199
|
}
|
|
200
200
|
latex() {
|
|
201
|
-
return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
|
|
201
|
+
return this.leftDelimExpr + " " + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
|
|
202
202
|
}
|
|
203
203
|
arabicLatex() {
|
|
204
204
|
const sup = this.superscript !== null ? this.superscript.arabicLatex() : "";
|
|
@@ -2052,6 +2052,31 @@ function formatDigits(value, digitForm = "western") {
|
|
|
2052
2052
|
}).join("");
|
|
2053
2053
|
}
|
|
2054
2054
|
|
|
2055
|
+
// src/editor/indexSequence.ts
|
|
2056
|
+
function isIndexComma(node) {
|
|
2057
|
+
return node.kind === "operator" && (node.expr === "," || node.expr === "\u060C");
|
|
2058
|
+
}
|
|
2059
|
+
function isValidIndexSequence(chain) {
|
|
2060
|
+
let count = 0;
|
|
2061
|
+
let afterComma = false;
|
|
2062
|
+
for (const node of chain.nodes) {
|
|
2063
|
+
if (node.superscript || node.subscript) return false;
|
|
2064
|
+
if (isIndexComma(node)) {
|
|
2065
|
+
if (count === 0 || afterComma) return false;
|
|
2066
|
+
afterComma = true;
|
|
2067
|
+
continue;
|
|
2068
|
+
}
|
|
2069
|
+
const isDigit = node.kind === "number" && /^[0-9]$/.test(node.expr);
|
|
2070
|
+
const identity = node.sourceLatex ?? node.expr;
|
|
2071
|
+
const isLetter = node.kind === "char" && (/^[A-Za-z]$/.test(identity) || Array.from(identity).length === 1 && /^\p{L}$/u.test(identity));
|
|
2072
|
+
if (!isDigit && !isLetter) return false;
|
|
2073
|
+
count += 1;
|
|
2074
|
+
afterComma = false;
|
|
2075
|
+
if (count > 64) return false;
|
|
2076
|
+
}
|
|
2077
|
+
return count >= 2 && !afterComma;
|
|
2078
|
+
}
|
|
2079
|
+
|
|
2055
2080
|
// src/editor/render.ts
|
|
2056
2081
|
function selectedDigitForm(options) {
|
|
2057
2082
|
return options?.digitForm ?? "western";
|
|
@@ -2179,7 +2204,11 @@ function renderNodeArabic(node, options) {
|
|
|
2179
2204
|
return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
|
|
2180
2205
|
}
|
|
2181
2206
|
function renderChainArabic(chain, options) {
|
|
2182
|
-
|
|
2207
|
+
const rendered = chain.nodes.slice().reverse().map((node) => renderNodeArabic(node, options));
|
|
2208
|
+
if (chain.indexSequence && isValidIndexSequence(chain)) {
|
|
2209
|
+
return "\\mathnormal{" + rendered.join("") + "}";
|
|
2210
|
+
}
|
|
2211
|
+
return rendered.join(" ");
|
|
2183
2212
|
}
|
|
2184
2213
|
function renderArabicLatexFromSession(session) {
|
|
2185
2214
|
return renderChainArabic(session.arabicTree, { digitForm: session.currentDigitForm ?? "western" });
|
|
@@ -3158,7 +3187,11 @@ function editorChainToAstChain(chain) {
|
|
|
3158
3187
|
}
|
|
3159
3188
|
nodes.push(converted.node);
|
|
3160
3189
|
}
|
|
3161
|
-
|
|
3190
|
+
const content = new ChainNode(nodes);
|
|
3191
|
+
if (chain.indexSequence && isValidIndexSequence(chain)) {
|
|
3192
|
+
return { ok: true, chain: new ChainNode([new CommandNode("\\mathnormal", [], [content])]) };
|
|
3193
|
+
}
|
|
3194
|
+
return { ok: true, chain: content };
|
|
3162
3195
|
}
|
|
3163
3196
|
function mathNodeFromEditorSession(session, mathMode = "$", closing = "$") {
|
|
3164
3197
|
const converted = editorChainToAstChain(session.englishTree);
|