@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.
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.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() : "";
@@ -2009,6 +2009,21 @@ function renderDivideOperatorLatex(side) {
2009
2009
  return side === "arabic" ? "\\backslash" : DIVIDE_OPERATOR_EN;
2010
2010
  }
2011
2011
 
2012
+ // src/editor/rawOperatorPresentation.ts
2013
+ var RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE = {
2014
+ "<": ">",
2015
+ ">": "<"
2016
+ };
2017
+ function renderRawOperatorLatex(expr, side) {
2018
+ if (isDivideOperatorExpr(expr)) {
2019
+ return renderDivideOperatorLatex(side);
2020
+ }
2021
+ if (side === "arabic" && Object.prototype.hasOwnProperty.call(RTL_DIRECTIONAL_RAW_OPERATOR_SURFACE, expr)) {
2022
+ return `\\butexmirror{${expr}}`;
2023
+ }
2024
+ return expr;
2025
+ }
2026
+
2012
2027
  // src/editor/digits.ts
2013
2028
  var WESTERN = "0123456789";
2014
2029
  var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
@@ -2158,8 +2173,8 @@ function renderNodeArabic(node, options) {
2158
2173
  }
2159
2174
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
2160
2175
  }
2161
- if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
2162
- return arabicScripts(node, renderDivideOperatorLatex("arabic"), options);
2176
+ if (node.kind === "operator") {
2177
+ return arabicScripts(node, renderRawOperatorLatex(node.expr, "arabic"), options);
2163
2178
  }
2164
2179
  return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
2165
2180
  }