@drghaliasri/butex 4.1.0 → 4.3.0

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/document2.js CHANGED
@@ -997,6 +997,16 @@ var ATOMIC_COMMANDS = {
997
997
  arabicLabel: "\u0645\u062D\u062F\u062F",
998
998
  title: "\u0645\u062D\u062F\u062F"
999
999
  },
1000
+ ////////////////////// Derivatives ////////////////////////////////
1001
+ ad: {
1002
+ id: "ad",
1003
+ category: "derivative",
1004
+ englishTex: "\\mathrm{d}",
1005
+ englishLabel: "d",
1006
+ arabicTex: "\\ad",
1007
+ arabicLabel: "\u0621",
1008
+ title: "\u0639\u0644\u0627\u0645\u0629 \u0627\u0644\u0627\u0634\u062A\u0642\u0627\u0642"
1009
+ },
1000
1010
  ////////////////////// Groups /////////////////////////////////
1001
1011
  N: {
1002
1012
  id: "N",
@@ -1745,6 +1755,16 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
1745
1755
  };
1746
1756
  }
1747
1757
 
1758
+ // src/editor/divideOperator.ts
1759
+ var DIVIDE_OPERATOR_EN = "/";
1760
+ var DIVIDE_OPERATOR_AR = "\\";
1761
+ function isDivideOperatorExpr(expr) {
1762
+ return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
1763
+ }
1764
+ function renderDivideOperatorLatex(side) {
1765
+ return side === "arabic" ? "\\backslash" : DIVIDE_OPERATOR_EN;
1766
+ }
1767
+
1748
1768
  // src/editor/digits.ts
1749
1769
  var WESTERN = "0123456789";
1750
1770
  var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
@@ -1893,6 +1913,9 @@ function renderNodeEnglish(node, options) {
1893
1913
  if (node.kind === "char") {
1894
1914
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
1895
1915
  }
1916
+ if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
1917
+ return `${renderDivideOperatorLatex("english")}${latinScripts(node, options)}`;
1918
+ }
1896
1919
  return `${formatDigits(node.expr, selectedDigitForm(options))}${latinScripts(node, options)}`;
1897
1920
  }
1898
1921
  function renderNodeArabic(node, options) {
@@ -1927,6 +1950,9 @@ function renderNodeArabic(node, options) {
1927
1950
  const content = renderCharContent(node, options);
1928
1951
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
1929
1952
  }
1953
+ if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
1954
+ return arabicScripts(node, renderDivideOperatorLatex("arabic"), options);
1955
+ }
1930
1956
  return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
1931
1957
  }
1932
1958
  function renderChainEnglish(chain, options) {
@@ -2579,6 +2605,19 @@ var COMMAND_FONT_MAP = {
2579
2605
  "\\butexdiwanioutline": "diwaniOutline",
2580
2606
  "\\diwanioutlineshaded": "diwaniOutline"
2581
2607
  };
2608
+ var CHAR_FONT_EXPORT_TEX = {
2609
+ takween: "\\butextakween",
2610
+ diwani: "\\butexdiwani",
2611
+ diwaniOutline: "\\butexdiwanioutline"
2612
+ };
2613
+ function charEditorNodeToAstNode(node) {
2614
+ const font = node.characterFont ?? "default";
2615
+ const charNode = new CharNode(node.expr);
2616
+ if (font === "default") {
2617
+ return charNode;
2618
+ }
2619
+ return new CommandNode(CHAR_FONT_EXPORT_TEX[font], [], [new ChainNode([charNode])]);
2620
+ }
2582
2621
  function commandIdForTex(tex) {
2583
2622
  for (const spec of Object.values(ATOMIC_COMMANDS)) {
2584
2623
  const renderTex = spec.arabicRenderTex;
@@ -2904,7 +2943,7 @@ function editorEnvToAstNode(node) {
2904
2943
  function editorNodeToAstNode(node) {
2905
2944
  let astNode;
2906
2945
  if (node.kind === "char") {
2907
- astNode = new CharNode(node.expr);
2946
+ astNode = charEditorNodeToAstNode(node);
2908
2947
  } else if (node.kind === "number") {
2909
2948
  astNode = new NumberNode(node.expr);
2910
2949
  } else if (node.kind === "operator") {