@drghaliasri/butex 7.2.1 → 7.3.0
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 +1 -0
- package/dist/document.d.mts +8 -0
- package/dist/document.d.ts +8 -0
- package/dist/document.js +37 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +37 -2
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +106 -2
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +8 -0
- package/dist/document2.d.ts +8 -0
- package/dist/document2.js +106 -2
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +106 -2
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.global.js +108 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +108 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -11
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.d.mts +2 -0
- package/dist/react-document.d.ts +2 -0
- package/dist/react-document.js +229 -40
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +229 -40
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.d.mts +2 -0
- package/dist/react-document2-preview.d.ts +2 -0
- package/dist/react-document2-preview.js +90 -0
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +90 -0
- package/dist/react-document2-preview.mjs.map +1 -1
- package/dist/react-document2.d.mts +8 -0
- package/dist/react-document2.d.ts +8 -0
- package/dist/react-document2.js +229 -40
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +229 -40
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +16 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +229 -40
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +229 -40
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document.mjs
CHANGED
|
@@ -14,6 +14,7 @@ var BaseAstNode = class {
|
|
|
14
14
|
superscript;
|
|
15
15
|
subscript;
|
|
16
16
|
nodeType;
|
|
17
|
+
sourceLatex;
|
|
17
18
|
constructor(state = null) {
|
|
18
19
|
if (state === null) {
|
|
19
20
|
state = new State();
|
|
@@ -22,6 +23,7 @@ var BaseAstNode = class {
|
|
|
22
23
|
this.superscript = null;
|
|
23
24
|
this.subscript = null;
|
|
24
25
|
this.nodeType = this.constructor.name;
|
|
26
|
+
this.sourceLatex = null;
|
|
25
27
|
}
|
|
26
28
|
latex() {
|
|
27
29
|
throw new Error("NotImplementedError");
|
|
@@ -210,6 +212,7 @@ ${this.closing}`;
|
|
|
210
212
|
}
|
|
211
213
|
};
|
|
212
214
|
function parseScripts(node, json, mode) {
|
|
215
|
+
node.sourceLatex = typeof json.source_latex === "string" && json.source_latex.length > 0 ? json.source_latex : null;
|
|
213
216
|
if (json.superscript) {
|
|
214
217
|
node.superscript = parseChain(json.superscript, mode);
|
|
215
218
|
}
|
|
@@ -349,7 +352,8 @@ function fromMathObjectJson(json, mode = "english") {
|
|
|
349
352
|
function scriptsToJson(node, path) {
|
|
350
353
|
return {
|
|
351
354
|
...node.superscript ? { superscript: chainToJson(node.superscript, `${path}.superscript`) } : {},
|
|
352
|
-
...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {}
|
|
355
|
+
...node.subscript ? { subscript: chainToJson(node.subscript, `${path}.subscript`) } : {},
|
|
356
|
+
...node.sourceLatex ? { source_latex: node.sourceLatex } : {}
|
|
353
357
|
};
|
|
354
358
|
}
|
|
355
359
|
function nodeToJson(node, path) {
|
|
@@ -1282,6 +1286,15 @@ var ATOMIC_OPERATOR_COMMANDS = {
|
|
|
1282
1286
|
title: "\u0627\u0644\u0644\u0627\u0646\u0647\u0627\u064A\u0629",
|
|
1283
1287
|
svg_path: null
|
|
1284
1288
|
},
|
|
1289
|
+
top: {
|
|
1290
|
+
id: "top",
|
|
1291
|
+
category: "operators1",
|
|
1292
|
+
Tex: "\\top",
|
|
1293
|
+
mirror: false,
|
|
1294
|
+
Label: "\u22A4",
|
|
1295
|
+
title: "\u0627\u0644\u0645\u0646\u0642\u0648\u0644",
|
|
1296
|
+
svg_path: null
|
|
1297
|
+
},
|
|
1285
1298
|
times: {
|
|
1286
1299
|
id: "times",
|
|
1287
1300
|
category: "operators1",
|
|
@@ -2070,6 +2083,10 @@ function renderNodeArabic(node, options) {
|
|
|
2070
2083
|
if (node.kind === "char") {
|
|
2071
2084
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
2072
2085
|
const content = renderCharContent(node, options);
|
|
2086
|
+
if (node.wrapperCommand) {
|
|
2087
|
+
const wrapper = node.wrapperCommand === "\\mathbf" ? "\\boldarabic" : node.wrapperCommand;
|
|
2088
|
+
return arabicScripts(node, `${wrapper}{${content}}`, options);
|
|
2089
|
+
}
|
|
2073
2090
|
return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
|
|
2074
2091
|
}
|
|
2075
2092
|
if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
|
|
@@ -2640,6 +2657,11 @@ ${BUTEX_FONT_FACE_CSS}
|
|
|
2640
2657
|
|
|
2641
2658
|
${CHARACTER_FONT_CSS}
|
|
2642
2659
|
|
|
2660
|
+
.node-value--bold {
|
|
2661
|
+
font-family: var(--font-display-ar, Amiri), "Noto Serif Arabic", serif;
|
|
2662
|
+
font-weight: 700;
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2643
2665
|
.chain {
|
|
2644
2666
|
display: inline-flex;
|
|
2645
2667
|
align-items: center;
|
|
@@ -2835,6 +2857,10 @@ var CHAR_FONT_EXPORT_TEX = Object.fromEntries(
|
|
|
2835
2857
|
function charEditorNodeToAstNode(node) {
|
|
2836
2858
|
const font = node.characterFont ?? "default";
|
|
2837
2859
|
const charNode = new CharNode(node.expr);
|
|
2860
|
+
if (node.wrapperCommand) {
|
|
2861
|
+
const wrapper = node.wrapperCommand === "\\boldarabic" ? "\\mathbf" : node.wrapperCommand;
|
|
2862
|
+
return new CommandNode(wrapper, [], [new ChainNode([charNode])]);
|
|
2863
|
+
}
|
|
2838
2864
|
if (font === "default") {
|
|
2839
2865
|
return charNode;
|
|
2840
2866
|
}
|
|
@@ -2980,7 +3006,13 @@ function editorNodeToAstNode(node) {
|
|
|
2980
3006
|
if (!tex) {
|
|
2981
3007
|
return { ok: false, reason: `\u0623\u0645\u0631 \u0631\u064A\u0627\u0636\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u062D\u0627\u0644\u064A\u0627: ${node.expr}` };
|
|
2982
3008
|
}
|
|
2983
|
-
|
|
3009
|
+
if (node.expr === "ad") {
|
|
3010
|
+
astNode = new CommandNode("\\mathrm", [], [new ChainNode([new CharNode("d")])]);
|
|
3011
|
+
} else if (["N", "Z", "Q", "R", "C", "H"].includes(node.expr)) {
|
|
3012
|
+
astNode = new CommandNode("\\mathbb", [], [new ChainNode([new CharNode(node.expr)])]);
|
|
3013
|
+
} else {
|
|
3014
|
+
astNode = new CommandNode(tex);
|
|
3015
|
+
}
|
|
2984
3016
|
} else if (node.kind === "atomicOperatorCommand") {
|
|
2985
3017
|
const tex = atomicOperatorCommandSpec(node.expr)?.Tex;
|
|
2986
3018
|
if (!tex) {
|
|
@@ -2997,6 +3029,9 @@ function editorNodeToAstNode(node) {
|
|
|
2997
3029
|
} else {
|
|
2998
3030
|
return { ok: false, reason: `\u0639\u0642\u062F\u0629 \u0631\u064A\u0627\u0636\u064A\u0629 \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645\u0629 \u062D\u0627\u0644\u064A\u0627: ${node.kind}` };
|
|
2999
3031
|
}
|
|
3032
|
+
if (node.sourceLatex) {
|
|
3033
|
+
astNode.sourceLatex = node.sourceLatex;
|
|
3034
|
+
}
|
|
3000
3035
|
const scripts = attachAstScripts(node, astNode);
|
|
3001
3036
|
return scripts ?? { ok: true, node: astNode };
|
|
3002
3037
|
}
|