@drghaliasri/butex 8.0.2 → 8.0.3
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/dist/document-cli.js +73 -2
- package/dist/document-cli.js.map +1 -1
- package/dist/document.js +6 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +6 -2
- package/dist/document.mjs.map +1 -1
- package/dist/react-document.js +6 -2
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +6 -2
- package/dist/react-document.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document-cli.js
CHANGED
|
@@ -3265,6 +3265,31 @@ function renderEnglishLatexFromSession(session) {
|
|
|
3265
3265
|
function renderArabicLatexFromSession(session) {
|
|
3266
3266
|
return renderChainArabic(session.arabicTree, { digitForm: session.currentDigitForm ?? "western" });
|
|
3267
3267
|
}
|
|
3268
|
+
function renderArabicPreviewLatexFromSession(session) {
|
|
3269
|
+
return renderChainArabic(session.arabicTree, { digitForm: session.currentDigitForm ?? "western", casesPresentation: true });
|
|
3270
|
+
}
|
|
3271
|
+
|
|
3272
|
+
// src/editor/state.ts
|
|
3273
|
+
function appendDebug(session, command, note) {
|
|
3274
|
+
const entry = {
|
|
3275
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3276
|
+
command,
|
|
3277
|
+
activeSide: session.activeSide,
|
|
3278
|
+
englishLatex: renderEnglishLatexFromSession(session),
|
|
3279
|
+
arabicLatex: renderArabicLatexFromSession(session),
|
|
3280
|
+
renderOk: true,
|
|
3281
|
+
renderError: null,
|
|
3282
|
+
note
|
|
3283
|
+
};
|
|
3284
|
+
const nextLog = session.debugLog.concat(entry);
|
|
3285
|
+
session.debugLog = nextLog.slice(-120);
|
|
3286
|
+
}
|
|
3287
|
+
function setCurrentDigitForm(session, digitForm) {
|
|
3288
|
+
const next = cloneEditorSession(session);
|
|
3289
|
+
next.currentDigitForm = digitForm;
|
|
3290
|
+
appendDebug(next, "setCurrentDigitForm", digitForm);
|
|
3291
|
+
return next;
|
|
3292
|
+
}
|
|
3268
3293
|
|
|
3269
3294
|
// src/editor/display/delimiter.ts
|
|
3270
3295
|
var DELIMITER_CSS = `
|
|
@@ -4814,6 +4839,48 @@ function mathNodeFromEditorSession(session, mathMode = "$", closing = "$") {
|
|
|
4814
4839
|
};
|
|
4815
4840
|
}
|
|
4816
4841
|
|
|
4842
|
+
// src/document/mathBridge.ts
|
|
4843
|
+
function mathTokenToEditorSession(math, side = "arabic") {
|
|
4844
|
+
if (!math) {
|
|
4845
|
+
return { editable: false, reason: "\u0647\u0630\u0647 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629 \u0645\u062D\u0641\u0648\u0638\u0629 \u0643\u0646\u0635 \u062E\u0627\u0645 \u0641\u0642\u0637 \u062D\u0627\u0644\u064A\u0627" };
|
|
4846
|
+
}
|
|
4847
|
+
const result = mathObjectToEditorSession(math);
|
|
4848
|
+
if (!result.editable) {
|
|
4849
|
+
return result;
|
|
4850
|
+
}
|
|
4851
|
+
result.session.activeSide = side;
|
|
4852
|
+
result.session.sync = buildInitialSyncMap(result.session.englishTree, result.session.arabicTree);
|
|
4853
|
+
return result;
|
|
4854
|
+
}
|
|
4855
|
+
function mathSourceFromSession(session, side, opening = "$", closing = "$", presentation = false) {
|
|
4856
|
+
const inner = side === "english" ? renderEnglishLatexFromSession(session) : presentation ? renderArabicPreviewLatexFromSession(session) : renderArabicLatexFromSession(session);
|
|
4857
|
+
if (opening === "$" || opening === "\\(") {
|
|
4858
|
+
return opening + inner + closing;
|
|
4859
|
+
}
|
|
4860
|
+
if (opening === "$$" || opening === "\\[") {
|
|
4861
|
+
return `${opening}
|
|
4862
|
+
${inner}
|
|
4863
|
+
${closing}`;
|
|
4864
|
+
}
|
|
4865
|
+
return `${opening}
|
|
4866
|
+
${inner}
|
|
4867
|
+
${closing}`;
|
|
4868
|
+
}
|
|
4869
|
+
function mathTokenSourceForSide(token, side, digitForm, presentation = false) {
|
|
4870
|
+
if (!token.math || token.sourceOwner === "raw") {
|
|
4871
|
+
return token.source;
|
|
4872
|
+
}
|
|
4873
|
+
if (!presentation && token.sourceSide === side && digitForm === void 0) {
|
|
4874
|
+
return token.source;
|
|
4875
|
+
}
|
|
4876
|
+
const result = mathTokenToEditorSession(token.math, side);
|
|
4877
|
+
if (!result.editable) {
|
|
4878
|
+
return token.source;
|
|
4879
|
+
}
|
|
4880
|
+
const session = digitForm === void 0 ? result.session : setCurrentDigitForm(result.session, digitForm);
|
|
4881
|
+
return mathSourceFromSession(session, side, token.opening, token.closing, presentation);
|
|
4882
|
+
}
|
|
4883
|
+
|
|
4817
4884
|
// src/document/keys.ts
|
|
4818
4885
|
var DOCUMENT_KEY_PATTERN = /^[\p{L}\p{M}\p{Nd}:._-]+$/u;
|
|
4819
4886
|
function normalizeDocumentKey(key) {
|
|
@@ -6949,9 +7016,13 @@ function digitsMappingFromDigitForm(digitForm) {
|
|
|
6949
7016
|
}
|
|
6950
7017
|
return "arabicdigits";
|
|
6951
7018
|
}
|
|
7019
|
+
function editorMathLatexForCompile(token) {
|
|
7020
|
+
const source = token.math && token.sourceSide === "arabic" && token.source.includes("\\begin{cases}") ? mathTokenSourceForSide(token, "arabic", void 0, true) : token.source;
|
|
7021
|
+
return mirrorBuTeXOperatorsInTex(source, { target: "compile" });
|
|
7022
|
+
}
|
|
6952
7023
|
function mathBodyLatex(token) {
|
|
6953
7024
|
if (token.sourceOwner === "editor") {
|
|
6954
|
-
return stripDisplayMathDelimiters(
|
|
7025
|
+
return stripDisplayMathDelimiters(editorMathLatexForCompile(token));
|
|
6955
7026
|
}
|
|
6956
7027
|
if (!token.math || token.sourceOwner === "raw") {
|
|
6957
7028
|
return stripDisplayMathDelimiters(token.source);
|
|
@@ -7026,7 +7097,7 @@ ${body}
|
|
|
7026
7097
|
\\end{equation}`;
|
|
7027
7098
|
}
|
|
7028
7099
|
if (token.sourceOwner === "editor") {
|
|
7029
|
-
return
|
|
7100
|
+
return editorMathLatexForCompile(token);
|
|
7030
7101
|
}
|
|
7031
7102
|
if (!token.math || token.sourceOwner === "raw") {
|
|
7032
7103
|
return token.source;
|