@drghaliasri/butex 5.3.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,9 +38,11 @@ function formatDigits(value, digitForm = "western") {
38
38
  }
39
39
 
40
40
  // src/document2/articleMeta.ts
41
- var BUTEX_BASMALA_LINE1 = "\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";
42
- var BUTEX_BASMALA_SALAWAT = "\u0635\u064E\u0644\u064E\u0651\u0649 \u0627\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
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";
43
44
  var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
45
+ ${BUTEX_BASMALA_LINE2}
44
46
  ${BUTEX_BASMALA_SALAWAT}`;
45
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";
46
48
  function escapeButexTextArg(text) {
@@ -54,26 +56,60 @@ function butexDiwaniDisplayLatex(text) {
54
56
  ${butexDiwaniDisplayTex(text)}
55
57
  \\]`;
56
58
  }
59
+ var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
57
60
  function butexBasmalaDisplayTex() {
58
- return `${butexDiwaniDisplayTex(BUTEX_BASMALA_LINE1)} \\\\ ${butexDiwaniDisplayTex(BUTEX_BASMALA_SALAWAT)}`;
61
+ return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
59
62
  }
60
63
  function butexBasmalaDisplayLatex() {
61
64
  return `\\[
62
65
  ${butexBasmalaDisplayTex()}
63
66
  \\]`;
64
67
  }
65
- function butexBasmalaTitlingPreamble() {
66
- return [
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 = [
67
97
  "\\usepackage{titling}",
68
98
  "\\pretitle{%",
69
99
  " \\begin{center}",
70
- ` ${butexDiwaniDisplayTex(BUTEX_BASMALA_LINE1)}\\\\`,
71
- ` ${butexDiwaniDisplayTex(BUTEX_BASMALA_SALAWAT)}`,
100
+ ...BASMALA_LINES.map((line, index) => {
101
+ const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
102
+ return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
103
+ }),
72
104
  " \\par\\vspace{1.5em}",
73
105
  " \\LARGE",
74
106
  "}",
75
107
  "\\posttitle{\\par\\end{center}}"
76
- ].join("\n");
108
+ ];
109
+ if (options.twocolumn) {
110
+ lines.push(butexInColumnMaketitleHook());
111
+ }
112
+ return lines.join("\n");
77
113
  }
78
114
  var HIJRI_YEAR_MIN = 1400;
79
115
  var HIJRI_YEAR_MAX = 1500;
@@ -7197,7 +7233,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
7197
7233
  kind: "image",
7198
7234
  command: "\\includegraphics",
7199
7235
  value: src,
7200
- options: { width: "0.8\\textwidth" },
7236
+ options: { width: "0.8\\columnwidth" },
7201
7237
  ...defaultFloatMeta()
7202
7238
  };
7203
7239
  return insertDocument2BlockAfter(document2, afterBlockId, block);
@@ -7797,8 +7833,16 @@ function tableBlockLatex(block) {
7797
7833
  lines.push("\\end{table}");
7798
7834
  return lines.join("\n");
7799
7835
  }
7800
- function imageOptionsLatex(block) {
7801
- 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
+ });
7802
7846
  if (entries.length === 0) {
7803
7847
  return "";
7804
7848
  }
@@ -7809,7 +7853,7 @@ function imageBlockLatex(block) {
7809
7853
  if (block.centered) {
7810
7854
  lines.push(" \\centering");
7811
7855
  }
7812
- lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
7856
+ lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
7813
7857
  lines.push(...floatCaptionLabelLines(block));
7814
7858
  lines.push("\\end{figure}");
7815
7859
  return lines.join("\n");
@@ -7839,11 +7883,11 @@ ${block.closing}`;
7839
7883
  function authorLatex(authors) {
7840
7884
  return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
7841
7885
  }
7842
- function articleMaketitlePreamble(meta) {
7886
+ function articleMaketitlePreamble(meta, twocolumn = false) {
7843
7887
  if (!document2HasMaketitle(meta)) {
7844
7888
  return "";
7845
7889
  }
7846
- const parts = [butexBasmalaTitlingPreamble()];
7890
+ const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
7847
7891
  if (meta.title.trim().length > 0) {
7848
7892
  parts.push(`\\title{${meta.title.trim()}}`);
7849
7893
  }
@@ -7869,21 +7913,22 @@ ${meta.abstract.trim()}
7869
7913
  }
7870
7914
  function document2Latex(document2, options = {}) {
7871
7915
  const meta = document2.meta ?? emptyDocument2Meta();
7916
+ const twocolumn = options.twocolumn === true;
7872
7917
  const front = articleFrontMatterLatex(meta);
7873
7918
  const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
7874
7919
  const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
7875
7920
  const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
7876
7921
  const wrapDocument = options.wrapDocument !== false;
7877
7922
  if (!wrapDocument) {
7878
- const metaPreamble = articleMaketitlePreamble(meta);
7923
+ const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
7879
7924
  return metaPreamble.length > 0 ? `${metaPreamble}
7880
7925
 
7881
7926
  ${body}` : body;
7882
7927
  }
7883
7928
  const preamble = getArabicXeLatexPreamble({
7884
7929
  digitsMapping: options.digitsMapping ?? "arabicdigits",
7885
- twocolumn: options.twocolumn === true
7886
- }) + "\n" + articleMaketitlePreamble(meta);
7930
+ twocolumn
7931
+ }) + "\n" + articleMaketitlePreamble(meta, twocolumn);
7887
7932
  return `${preamble}
7888
7933
  \\begin{document}
7889
7934
 
@@ -8528,6 +8573,8 @@ function ArticleMetaPanel({
8528
8573
  /* @__PURE__ */ jsxs("p", { className: "butex-document2-widget__article-meta-fixed", dir: "rtl", children: [
8529
8574
  BUTEX_BASMALA_LINE1,
8530
8575
  /* @__PURE__ */ jsx("br", {}),
8576
+ BUTEX_BASMALA_LINE2,
8577
+ /* @__PURE__ */ jsx("br", {}),
8531
8578
  BUTEX_BASMALA_SALAWAT
8532
8579
  ] }),
8533
8580
  /* @__PURE__ */ jsxs("div", { className: "butex-document2-widget__article-meta-grid", children: [