@drghaliasri/butex 7.3.2 → 7.3.4

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.
@@ -137,7 +137,7 @@ var DelimiterNode = class extends BaseAstNode {
137
137
  this.rightDelimExpr = rightDelimExpr2;
138
138
  }
139
139
  latex() {
140
- return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
140
+ return this.leftDelimExpr + " " + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
141
141
  }
142
142
  arabicLatex() {
143
143
  const sup = this.superscript !== null ? this.superscript.arabicLatex() : "";
@@ -2207,6 +2207,30 @@ function renderDivideOperatorLatex(side) {
2207
2207
  return side === "arabic" ? "\\backslash" : DIVIDE_OPERATOR_EN;
2208
2208
  }
2209
2209
 
2210
+ // src/editor/rawOperatorPresentation.ts
2211
+ var RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE = {
2212
+ "<": ">",
2213
+ ">": "<"
2214
+ };
2215
+ function rawOperatorSurfaceExpr(expr, side) {
2216
+ if (isDivideOperatorExpr(expr)) {
2217
+ return divideOperatorSurfaceExpr(expr, side);
2218
+ }
2219
+ if (side === "arabic") {
2220
+ return RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE[expr] ?? expr;
2221
+ }
2222
+ return expr;
2223
+ }
2224
+ function renderRawOperatorLatex(expr, side) {
2225
+ if (isDivideOperatorExpr(expr)) {
2226
+ return renderDivideOperatorLatex(side);
2227
+ }
2228
+ if (side === "arabic" && Object.prototype.hasOwnProperty.call(RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE, expr)) {
2229
+ return `\\butexmirror{${expr}}`;
2230
+ }
2231
+ return expr;
2232
+ }
2233
+
2210
2234
  // src/editor/digits.ts
2211
2235
  var WESTERN = "0123456789";
2212
2236
  var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
@@ -2342,7 +2366,7 @@ function renderCharContent(node, options) {
2342
2366
  }
2343
2367
  function renderNodeEnglish(node, options) {
2344
2368
  if (node.kind === "delimiter" && node.innerExpr) {
2345
- return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
2369
+ return `${node.leftDelimExpr} ${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
2346
2370
  }
2347
2371
  if (node.kind === "boxed" && node.innerExpr) {
2348
2372
  const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
@@ -2394,8 +2418,8 @@ function renderNodeEnglish(node, options) {
2394
2418
  }
2395
2419
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
2396
2420
  }
2397
- if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
2398
- return `${renderDivideOperatorLatex("english")}${latinScripts(node, options)}`;
2421
+ if (node.kind === "operator") {
2422
+ return `${renderRawOperatorLatex(node.expr, "english")}${latinScripts(node, options)}`;
2399
2423
  }
2400
2424
  return `${formatDigits(node.expr, selectedDigitForm(options))}${latinScripts(node, options)}`;
2401
2425
  }
@@ -2455,8 +2479,8 @@ function renderNodeArabic(node, options) {
2455
2479
  }
2456
2480
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
2457
2481
  }
2458
- if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
2459
- return arabicScripts(node, renderDivideOperatorLatex("arabic"), options);
2482
+ if (node.kind === "operator") {
2483
+ return arabicScripts(node, renderRawOperatorLatex(node.expr, "arabic"), options);
2460
2484
  }
2461
2485
  return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
2462
2486
  }
@@ -5150,7 +5174,7 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
5150
5174
  value.title = "\u0648\u062D\u062F\u0629 (unit)";
5151
5175
  }
5152
5176
  }
5153
- const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
5177
+ const surfaceExpr = node.kind === "operator" ? rawOperatorSurfaceExpr(node.expr, side) : node.expr;
5154
5178
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
5155
5179
  return value;
5156
5180
  }