@drghaliasri/butex 5.2.0 → 5.3.1

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.
@@ -38,7 +38,12 @@ function formatDigits(value, digitForm = "western") {
38
38
  }
39
39
 
40
40
  // src/document2/articleMeta.ts
41
- var BUTEX_BASMALA = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0627\u0644\u0644\u064E\u0651\u0647\u0650 \u0627\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0627\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650 \u0648\u064E\u0627\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0627\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0627\u0644\u0644\u064E\u0651\u0647\u0650 \uFDFA";
41
+ var BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650";
42
+ var BUTEX_BASMALA_LINE2 = "\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650";
43
+ var BUTEX_BASMALA_SALAWAT = "\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
44
+ var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
45
+ ${BUTEX_BASMALA_LINE2}
46
+ ${BUTEX_BASMALA_SALAWAT}`;
42
47
  var BUTEX_CLOSING_HAMDALA = "\u0627\u0644\u0652\u062D\u064E\u0645\u0652\u062F\u064F \u0644\u0650\u0644\u064E\u0651\u0647\u0650 \u0646\u064E\u0641\u064E\u0639\u064E\u0646\u064E\u0627 \u0628\u0650\u0639\u0650\u0644\u0652\u0645\u0650\u0647\u0650";
43
48
  function escapeButexTextArg(text) {
44
49
  return text.replace(/\\/g, "\\textbackslash{}").replace(/[{}]/g, "\\$&");
@@ -51,6 +56,61 @@ function butexDiwaniDisplayLatex(text) {
51
56
  ${butexDiwaniDisplayTex(text)}
52
57
  \\]`;
53
58
  }
59
+ var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
60
+ function butexBasmalaDisplayTex() {
61
+ return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
62
+ }
63
+ function butexBasmalaDisplayLatex() {
64
+ return `\\[
65
+ ${butexBasmalaDisplayTex()}
66
+ \\]`;
67
+ }
68
+ function butexInColumnMaketitleHook() {
69
+ return String.raw`\makeatletter
70
+ \renewcommand{\maketitle}{%
71
+ \par
72
+ \begingroup
73
+ \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
74
+ \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
75
+ \long\def\@makefntext##1{\parindent 1em\noindent
76
+ \hb@xt@1.8em{\hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
77
+ \@maketitle
78
+ \thispagestyle{plain}\@thanks
79
+ \endgroup
80
+ \setcounter{footnote}{0}%
81
+ \global\let\thanks\relax
82
+ \global\let\maketitle\relax
83
+ \global\let\@maketitle\relax
84
+ \global\let\@thanks\@empty
85
+ \global\let\@author\@empty
86
+ \global\let\@date\@empty
87
+ \global\let\@title\@empty
88
+ \global\let\title\relax
89
+ \global\let\author\relax
90
+ \global\let\date\relax
91
+ \global\let\and\relax
92
+ }
93
+ \makeatother`;
94
+ }
95
+ function butexBasmalaTitlingPreamble(options = {}) {
96
+ const lines = [
97
+ "\\usepackage{titling}",
98
+ "\\pretitle{%",
99
+ " \\begin{center}",
100
+ ...BASMALA_LINES.map((line, index) => {
101
+ const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
102
+ return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
103
+ }),
104
+ " \\par\\vspace{1.5em}",
105
+ " \\LARGE",
106
+ "}",
107
+ "\\posttitle{\\par\\end{center}}"
108
+ ];
109
+ if (options.twocolumn) {
110
+ lines.push(butexInColumnMaketitleHook());
111
+ }
112
+ return lines.join("\n");
113
+ }
54
114
  var HIJRI_YEAR_MIN = 1400;
55
115
  var HIJRI_YEAR_MAX = 1500;
56
116
  var HIJRI_MONTH_IDS = [
@@ -7173,7 +7233,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
7173
7233
  kind: "image",
7174
7234
  command: "\\includegraphics",
7175
7235
  value: src,
7176
- options: { width: "0.8\\textwidth" },
7236
+ options: { width: "0.8\\columnwidth" },
7177
7237
  ...defaultFloatMeta()
7178
7238
  };
7179
7239
  return insertDocument2BlockAfter(document2, afterBlockId, block);
@@ -7493,7 +7553,7 @@ function updateDocument2Meta(document2, patch) {
7493
7553
 
7494
7554
  // src/document2/arabicPreamble.ts
7495
7555
  function arabicXeLatexPreamblePkg(twocolumn = false) {
7496
- const classOptions = twocolumn ? "12pt,a4paper,twocolumn" : "12pt,a4paper";
7556
+ const classOptions = twocolumn ? "12pt,a4paper,notitlepage,twocolumn" : "12pt,a4paper,notitlepage";
7497
7557
  return `
7498
7558
  \\documentclass[${classOptions}]{article}
7499
7559
  ` + String.raw`\usepackage{amsmath,amsfonts,amssymb,mathrsfs,tikz,fancyhdr, mathtools}
@@ -7773,8 +7833,16 @@ function tableBlockLatex(block) {
7773
7833
  lines.push("\\end{table}");
7774
7834
  return lines.join("\n");
7775
7835
  }
7776
- function imageOptionsLatex(block) {
7777
- const entries = Object.entries(block.options);
7836
+ function remapImageWidthForColumns(value) {
7837
+ return value.replace(/\\textwidth\b/g, "\\columnwidth");
7838
+ }
7839
+ function imageOptionsLatex(block, constrainToColumn) {
7840
+ const entries = Object.entries(block.options).map(([key, value]) => {
7841
+ if (constrainToColumn && key === "width") {
7842
+ return [key, remapImageWidthForColumns(value)];
7843
+ }
7844
+ return [key, value];
7845
+ });
7778
7846
  if (entries.length === 0) {
7779
7847
  return "";
7780
7848
  }
@@ -7785,7 +7853,7 @@ function imageBlockLatex(block) {
7785
7853
  if (block.centered) {
7786
7854
  lines.push(" \\centering");
7787
7855
  }
7788
- lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
7856
+ lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
7789
7857
  lines.push(...floatCaptionLabelLines(block));
7790
7858
  lines.push("\\end{figure}");
7791
7859
  return lines.join("\n");
@@ -7815,17 +7883,26 @@ ${block.closing}`;
7815
7883
  function authorLatex(authors) {
7816
7884
  return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
7817
7885
  }
7886
+ function articleMaketitlePreamble(meta, twocolumn = false) {
7887
+ if (!document2HasMaketitle(meta)) {
7888
+ return "";
7889
+ }
7890
+ const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
7891
+ if (meta.title.trim().length > 0) {
7892
+ parts.push(`\\title{${meta.title.trim()}}`);
7893
+ }
7894
+ if (meta.authors.trim().length > 0) {
7895
+ parts.push(`\\author{${authorLatex(meta.authors)}}`);
7896
+ }
7897
+ parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "arabicIndic" })}}`);
7898
+ return parts.join("\n");
7899
+ }
7818
7900
  function articleFrontMatterLatex(meta) {
7819
- const parts = [butexDiwaniDisplayLatex(BUTEX_BASMALA)];
7901
+ const parts = [];
7820
7902
  if (document2HasMaketitle(meta)) {
7821
- if (meta.title.trim().length > 0) {
7822
- parts.push(`\\title{${meta.title.trim()}}`);
7823
- }
7824
- if (meta.authors.trim().length > 0) {
7825
- parts.push(`\\author{${authorLatex(meta.authors)}}`);
7826
- }
7827
- parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "arabicIndic" })}}`);
7828
7903
  parts.push("\\maketitle");
7904
+ } else {
7905
+ parts.push(butexBasmalaDisplayLatex());
7829
7906
  }
7830
7907
  if (document2HasAbstract(meta)) {
7831
7908
  parts.push(`\\begin{abstract}
@@ -7836,18 +7913,22 @@ ${meta.abstract.trim()}
7836
7913
  }
7837
7914
  function document2Latex(document2, options = {}) {
7838
7915
  const meta = document2.meta ?? emptyDocument2Meta();
7916
+ const twocolumn = options.twocolumn === true;
7839
7917
  const front = articleFrontMatterLatex(meta);
7840
7918
  const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
7841
7919
  const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
7842
7920
  const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
7843
7921
  const wrapDocument = options.wrapDocument !== false;
7844
7922
  if (!wrapDocument) {
7845
- return body;
7923
+ const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
7924
+ return metaPreamble.length > 0 ? `${metaPreamble}
7925
+
7926
+ ${body}` : body;
7846
7927
  }
7847
7928
  const preamble = getArabicXeLatexPreamble({
7848
7929
  digitsMapping: options.digitsMapping ?? "arabicdigits",
7849
- twocolumn: options.twocolumn === true
7850
- });
7930
+ twocolumn
7931
+ }) + "\n" + articleMaketitlePreamble(meta, twocolumn);
7851
7932
  return `${preamble}
7852
7933
  \\begin{document}
7853
7934
 
@@ -8090,7 +8171,7 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
8090
8171
  function articleChromePreview(document2, uiLocale, previewOptions) {
8091
8172
  const meta = document2.meta ?? emptyDocument2Meta();
8092
8173
  const blocks = [
8093
- { kind: "basmala", id: "article-basmala", text: BUTEX_BASMALA, tex: butexDiwaniDisplayTex(BUTEX_BASMALA) }
8174
+ { kind: "basmala", id: "article-basmala", text: BUTEX_BASMALA, tex: butexBasmalaDisplayTex() }
8094
8175
  ];
8095
8176
  if (document2HasMaketitle(meta)) {
8096
8177
  blocks.push({
@@ -8489,7 +8570,13 @@ function ArticleMetaPanel({
8489
8570
  /* @__PURE__ */ jsx("strong", { children: messages.articleMetaTitle }),
8490
8571
  /* @__PURE__ */ jsx("span", { className: "butex-document2-widget__article-meta-badge", children: messages.articleMetaBadge })
8491
8572
  ] }),
8492
- /* @__PURE__ */ jsx("p", { className: "butex-document2-widget__article-meta-fixed", dir: "rtl", children: BUTEX_BASMALA }),
8573
+ /* @__PURE__ */ jsxs("p", { className: "butex-document2-widget__article-meta-fixed", dir: "rtl", children: [
8574
+ BUTEX_BASMALA_LINE1,
8575
+ /* @__PURE__ */ jsx("br", {}),
8576
+ BUTEX_BASMALA_LINE2,
8577
+ /* @__PURE__ */ jsx("br", {}),
8578
+ BUTEX_BASMALA_SALAWAT
8579
+ ] }),
8493
8580
  /* @__PURE__ */ jsxs("div", { className: "butex-document2-widget__article-meta-grid", children: [
8494
8581
  /* @__PURE__ */ jsxs("label", { className: "butex-document2-widget__article-meta-field", children: [
8495
8582
  /* @__PURE__ */ jsx("span", { children: messages.articleTitle }),