@drghaliasri/butex 5.5.1 → 5.5.2

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
@@ -19,8 +19,8 @@ The intended editor model is **AST-first**:
19
19
  ## Rendering outputs and MVP scope
20
20
 
21
21
  - **CommonHTML (`chtml`)** and **SVG** are supported. Load the matching MathJax 4 bundle (`tex-chtml.js` vs `tex-svg.js`) and pass the same mode as `output` to `renderBuTeXMathIsland` / `mountBuTeXMathIsland`. `<ButexEditor />` and document math preview follow the loaded bundle when possible (`tex2chtml` vs `tex2svg`).
22
- - `\arabsqrt`: optional index + mandatory radicand (same argument shape as `\sqrt`).
23
- - Compatibility macros: `\arsqrt` aliases `\arabsqrt`; `\unit{...}` and `\idx{...}` are browser-side passthrough wrappers for imported/reference TeX.
22
+ - `\arsqrt`: canonical serialized Arabic TeX command with an optional index and mandatory radicand (same argument shape as `\sqrt`).
23
+ - Compatibility macros: MathJax accepts `\arabsqrt` as an alias of `\arsqrt`; `\unit{...}` and `\idx{...}` are browser-side passthrough wrappers for imported/reference TeX.
24
24
  - **Arabic surface parser** (`parseBuTeX`) — optional helper that maps a tiny subset of Arabic command names to MathJax-safe TeX before rendering (see below). Long-term editor state is structured AST/JSON, not this string transform alone.
25
25
 
26
26
  ## Arabic preprocessor (`parseBuTeX`)
@@ -254,7 +254,7 @@ const latex = document2Latex(documentNode);
254
254
  const preview = document2Preview(documentNode, 'svg');
255
255
  ```
256
256
 
257
- `document2Latex(doc)` emits a **complete Arabic XeLaTeX document** by default (preamble + `\begin{document}` + body + `\end{document}`). Pass `{ wrapDocument: false }` for body-only blocks. Paragraph blocks export as `\par` followed by the inline content, so prose, citations, and math are not wrapped inside `\paragraph{...}`. Optional `digitsMapping: 'arabicdigits' | 'digits'` controls eastern vs western digit font mapping in the preamble (default `'arabicdigits'`). Pass `{ twocolumn: true }` for `\documentclass[12pt,a4paper,notitlepage,twocolumn]{article}` (title block stays in-column; figures use `\columnwidth`). See [`examples/example-latex-export.tex`](examples/example-latex-export.tex) for a full sample (regenerated by the wrap vitest). Hosts can also call `getArabicXeLatexPreamble()` alone.
257
+ `document2Latex(doc)` emits a **complete Arabic XeLaTeX document** by default (preamble + `\begin{document}` + body + `\end{document}`). Structured and editor-authored Arabic roots serialize with the canonical `\arsqrt`; the bundled preamble also accepts raw legacy `\arabsqrt` with the same optional-index signature. Pass `{ wrapDocument: false }` for body-only blocks. Paragraph blocks export as `\par` followed by the inline content, so prose, citations, and math are not wrapped inside `\paragraph{...}`. Optional `digitsMapping: 'arabicdigits' | 'digits'` controls eastern vs western digit font mapping in the preamble (default `'arabicdigits'`). Pass `{ twocolumn: true }` for `\documentclass[12pt,a4paper,notitlepage,twocolumn]{article}` (title block stays in-column; figures use `\columnwidth`). See [`examples/example-latex-export.tex`](examples/example-latex-export.tex) for a full sample (regenerated by the wrap vitest). Hosts can also call `getArabicXeLatexPreamble()` alone.
258
258
 
259
259
  Figures and tables always export as centered `figure` / `table` floats. Optional caption/label fields (checkbox-driven in the editor) emit `\caption` / `\label`. Display math stays `\[…\]` unless an equation label is enabled, then export uses `\begin{equation}…\label{…}\end{equation}`. Internal cross-refs use `\ref` / `\eqref` tokens (separate from bibliography `\cite`).
260
260
 
package/dist/document.js CHANGED
@@ -227,7 +227,7 @@ var CommandNode = class extends BaseAstNode {
227
227
  arabicLatex() {
228
228
  const sup = this.superscript !== null ? this.superscript.arabicLatex() : "";
229
229
  const sub = this.subscript !== null ? this.subscript.arabicLatex() : "";
230
- const arabicName = this.name === "\\sqrt" ? "\\arabsqrt" : this.name;
230
+ const arabicName = this.name === "\\sqrt" || this.name === "\\arabsqrt" ? "\\arsqrt" : this.name;
231
231
  const content = renderCommandCore({
232
232
  name: arabicName,
233
233
  optionalArgs: this.optionalArgs,
@@ -1898,7 +1898,7 @@ function renderNodeArabic(node, options) {
1898
1898
  return arabicScripts(node, content, options);
1899
1899
  }
1900
1900
  if (node.kind === "sqrt" && node.radicand) {
1901
- const content = `\\arabsqrt${optionalRootIndexArabic(node, options)}{${renderChainArabic(node.radicand, options)}}`;
1901
+ const content = `\\arsqrt${optionalRootIndexArabic(node, options)}{${renderChainArabic(node.radicand, options)}}`;
1902
1902
  return arabicScripts(node, content, options);
1903
1903
  }
1904
1904
  if (node.kind === "overset" && node.baseExpr) {