@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.
@@ -932,6 +932,16 @@ var ATOMIC_COMMANDS = {
932
932
  arabicLabel: "\u0645\u062D\u062F\u062F",
933
933
  title: "\u0645\u062D\u062F\u062F"
934
934
  },
935
+ ////////////////////// Derivatives ////////////////////////////////
936
+ ad: {
937
+ id: "ad",
938
+ category: "derivative",
939
+ englishTex: "\\mathrm{d}",
940
+ englishLabel: "d",
941
+ arabicTex: "\\ad",
942
+ arabicLabel: "\u0621",
943
+ title: "\u0639\u0644\u0627\u0645\u0629 \u0627\u0644\u0627\u0634\u062A\u0642\u0627\u0642"
944
+ },
935
945
  ////////////////////// Groups /////////////////////////////////
936
946
  N: {
937
947
  id: "N",
@@ -1680,6 +1690,16 @@ function createEditorSession(englishTree, arabicTree, activeSide = "arabic") {
1680
1690
  };
1681
1691
  }
1682
1692
 
1693
+ // src/editor/divideOperator.ts
1694
+ var DIVIDE_OPERATOR_EN = "/";
1695
+ var DIVIDE_OPERATOR_AR = "\\";
1696
+ function isDivideOperatorExpr(expr) {
1697
+ return expr === DIVIDE_OPERATOR_EN || expr === DIVIDE_OPERATOR_AR;
1698
+ }
1699
+ function renderDivideOperatorLatex(side) {
1700
+ return side === "arabic" ? "\\backslash" : DIVIDE_OPERATOR_EN;
1701
+ }
1702
+
1683
1703
  // src/editor/digits.ts
1684
1704
  var WESTERN = "0123456789";
1685
1705
  var ARABIC_INDIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
@@ -1828,6 +1848,9 @@ function renderNodeEnglish(node, options) {
1828
1848
  if (node.kind === "char") {
1829
1849
  return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
1830
1850
  }
1851
+ if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
1852
+ return `${renderDivideOperatorLatex("english")}${latinScripts(node, options)}`;
1853
+ }
1831
1854
  return `${formatDigits(node.expr, selectedDigitForm(options))}${latinScripts(node, options)}`;
1832
1855
  }
1833
1856
  function renderNodeArabic(node, options) {
@@ -1862,6 +1885,9 @@ function renderNodeArabic(node, options) {
1862
1885
  const content = renderCharContent(node, options);
1863
1886
  return arabicScripts(node, (node.characterFont ?? "default") === "default" ? `\\text{${escapeText(expr)}}` : content, options);
1864
1887
  }
1888
+ if (node.kind === "operator" && isDivideOperatorExpr(node.expr)) {
1889
+ return arabicScripts(node, renderDivideOperatorLatex("arabic"), options);
1890
+ }
1865
1891
  return arabicScripts(node, formatDigits(node.expr, selectedDigitForm(options)), options);
1866
1892
  }
1867
1893
  function renderChainEnglish(chain, options) {
@@ -2514,6 +2540,19 @@ var COMMAND_FONT_MAP = {
2514
2540
  "\\butexdiwanioutline": "diwaniOutline",
2515
2541
  "\\diwanioutlineshaded": "diwaniOutline"
2516
2542
  };
2543
+ var CHAR_FONT_EXPORT_TEX = {
2544
+ takween: "\\butextakween",
2545
+ diwani: "\\butexdiwani",
2546
+ diwaniOutline: "\\butexdiwanioutline"
2547
+ };
2548
+ function charEditorNodeToAstNode(node) {
2549
+ const font = node.characterFont ?? "default";
2550
+ const charNode = new CharNode(node.expr);
2551
+ if (font === "default") {
2552
+ return charNode;
2553
+ }
2554
+ return new CommandNode(CHAR_FONT_EXPORT_TEX[font], [], [new ChainNode([charNode])]);
2555
+ }
2517
2556
  function commandIdForTex(tex) {
2518
2557
  for (const spec of Object.values(ATOMIC_COMMANDS)) {
2519
2558
  const renderTex = spec.arabicRenderTex;
@@ -2839,7 +2878,7 @@ function editorEnvToAstNode(node) {
2839
2878
  function editorNodeToAstNode(node) {
2840
2879
  let astNode;
2841
2880
  if (node.kind === "char") {
2842
- astNode = new CharNode(node.expr);
2881
+ astNode = charEditorNodeToAstNode(node);
2843
2882
  } else if (node.kind === "number") {
2844
2883
  astNode = new NumberNode(node.expr);
2845
2884
  } else if (node.kind === "operator") {