@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.
@@ -166,7 +166,7 @@ var DelimiterNode = class extends BaseAstNode {
166
166
  this.rightDelimExpr = rightDelimExpr2;
167
167
  }
168
168
  latex() {
169
- return this.leftDelimExpr + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
169
+ return this.leftDelimExpr + " " + this.innerExpr.latex() + this.rightDelimExpr + this.latexScripts();
170
170
  }
171
171
  arabicLatex() {
172
172
  const sup = this.superscript !== null ? this.superscript.arabicLatex() : "";
@@ -2236,6 +2236,30 @@ function renderDivideOperatorLatex(side) {
2236
2236
  return side === "arabic" ? "\\backslash" : DIVIDE_OPERATOR_EN;
2237
2237
  }
2238
2238
 
2239
+ // src/editor/rawOperatorPresentation.ts
2240
+ var RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE = {
2241
+ "<": ">",
2242
+ ">": "<"
2243
+ };
2244
+ function rawOperatorSurfaceExpr(expr, side) {
2245
+ if (isDivideOperatorExpr(expr)) {
2246
+ return divideOperatorSurfaceExpr(expr, side);
2247
+ }
2248
+ if (side === "arabic") {
2249
+ return RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE[expr] ?? expr;
2250
+ }
2251
+ return expr;
2252
+ }
2253
+ function renderRawOperatorLatex(expr, side) {
2254
+ if (isDivideOperatorExpr(expr)) {
2255
+ return renderDivideOperatorLatex(side);
2256
+ }
2257
+ if (side === "arabic" && Object.prototype.hasOwnProperty.call(RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE, expr)) {
2258
+ return `\\butexmirror{${expr}}`;
2259
+ }
2260
+ return expr;
2261
+ }
2262
+
2239
2263
  // src/editor/digits.ts
2240
2264
  var WESTERN = "0123456789";
2241
2265
  var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
@@ -2371,7 +2395,7 @@ function renderCharContent(node, options) {
2371
2395
  }
2372
2396
  function renderNodeEnglish(node, options) {
2373
2397
  if (node.kind === "delimiter" && node.innerExpr) {
2374
- return `${node.leftDelimExpr}${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
2398
+ return `${node.leftDelimExpr} ${renderChainEnglish(node.innerExpr, options)}${node.rightDelimExpr}${latinScripts(node, options)}`;
2375
2399
  }
2376
2400
  if (node.kind === "boxed" && node.innerExpr) {
2377
2401
  const body = `\\boxed{${renderChainEnglish(node.innerExpr, options)}}`;
@@ -2423,8 +2447,8 @@ function renderNodeEnglish(node, options) {
2423
2447
  }
2424
2448
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
2425
2449
  }
2426
- if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
2427
- return `${renderDivideOperatorLatex("english")}${latinScripts(node, options)}`;
2450
+ if (node.kind === "operator") {
2451
+ return `${renderRawOperatorLatex(node.expr, "english")}${latinScripts(node, options)}`;
2428
2452
  }
2429
2453
  return `${formatDigits(node.expr, selectedDigitForm(options))}${latinScripts(node, options)}`;
2430
2454
  }
@@ -2484,8 +2508,8 @@ function renderNodeArabic(node, options) {
2484
2508
  }
2485
2509
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
2486
2510
  }
2487
- if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
2488
- return arabicScripts(node, renderDivideOperatorLatex("arabic"), options);
2511
+ if (node.kind === "operator") {
2512
+ return arabicScripts(node, renderRawOperatorLatex(node.expr, "arabic"), options);
2489
2513
  }
2490
2514
  return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
2491
2515
  }
@@ -5179,7 +5203,7 @@ function buildBaseNodeBody(node, digitForm = "western", side = "english") {
5179
5203
  value.title = "\u0648\u062D\u062F\u0629 (unit)";
5180
5204
  }
5181
5205
  }
5182
- const surfaceExpr = node.kind === "operator" ? divideOperatorSurfaceExpr(node.expr, side) : node.expr;
5206
+ const surfaceExpr = node.kind === "operator" ? rawOperatorSurfaceExpr(node.expr, side) : node.expr;
5183
5207
  value.textContent = surfaceExpr === "" ? "\u25A1" : formatDigits(surfaceExpr, digitForm);
5184
5208
  return value;
5185
5209
  }