@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.
@@ -73,9 +73,11 @@ function formatDigits(value, digitForm = "western") {
73
73
  }
74
74
 
75
75
  // src/document2/articleMeta.ts
76
- 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";
77
- 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";
76
+ 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";
77
+ 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";
78
+ 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";
78
79
  var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
80
+ ${BUTEX_BASMALA_LINE2}
79
81
  ${BUTEX_BASMALA_SALAWAT}`;
80
82
  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";
81
83
  function escapeButexTextArg(text) {
@@ -89,26 +91,60 @@ function butexDiwaniDisplayLatex(text) {
89
91
  ${butexDiwaniDisplayTex(text)}
90
92
  \\]`;
91
93
  }
94
+ var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
92
95
  function butexBasmalaDisplayTex() {
93
- return `${butexDiwaniDisplayTex(BUTEX_BASMALA_LINE1)} \\\\ ${butexDiwaniDisplayTex(BUTEX_BASMALA_SALAWAT)}`;
96
+ return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
94
97
  }
95
98
  function butexBasmalaDisplayLatex() {
96
99
  return `\\[
97
100
  ${butexBasmalaDisplayTex()}
98
101
  \\]`;
99
102
  }
100
- function butexBasmalaTitlingPreamble() {
101
- return [
103
+ function butexInColumnMaketitleHook() {
104
+ return String.raw`\makeatletter
105
+ \renewcommand{\maketitle}{%
106
+ \par
107
+ \begingroup
108
+ \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
109
+ \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
110
+ \long\def\@makefntext##1{\parindent 1em\noindent
111
+ \hb@xt@1.8em{\hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
112
+ \@maketitle
113
+ \thispagestyle{plain}\@thanks
114
+ \endgroup
115
+ \setcounter{footnote}{0}%
116
+ \global\let\thanks\relax
117
+ \global\let\maketitle\relax
118
+ \global\let\@maketitle\relax
119
+ \global\let\@thanks\@empty
120
+ \global\let\@author\@empty
121
+ \global\let\@date\@empty
122
+ \global\let\@title\@empty
123
+ \global\let\title\relax
124
+ \global\let\author\relax
125
+ \global\let\date\relax
126
+ \global\let\and\relax
127
+ }
128
+ \makeatother`;
129
+ }
130
+ function butexBasmalaTitlingPreamble(options = {}) {
131
+ const lines = [
102
132
  "\\usepackage{titling}",
103
133
  "\\pretitle{%",
104
134
  " \\begin{center}",
105
- ` ${butexDiwaniDisplayTex(BUTEX_BASMALA_LINE1)}\\\\`,
106
- ` ${butexDiwaniDisplayTex(BUTEX_BASMALA_SALAWAT)}`,
135
+ ...BASMALA_LINES.map((line, index) => {
136
+ const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
137
+ return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
138
+ }),
107
139
  " \\par\\vspace{1.5em}",
108
140
  " \\LARGE",
109
141
  "}",
110
142
  "\\posttitle{\\par\\end{center}}"
111
- ].join("\n");
143
+ ];
144
+ if (options.twocolumn) {
145
+ lines.push(butexInColumnMaketitleHook());
146
+ }
147
+ return lines.join("\n");
112
148
  }
113
149
  var HIJRI_YEAR_MIN = 1400;
114
150
  var HIJRI_YEAR_MAX = 1500;
@@ -7232,7 +7268,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
7232
7268
  kind: "image",
7233
7269
  command: "\\includegraphics",
7234
7270
  value: src,
7235
- options: { width: "0.8\\textwidth" },
7271
+ options: { width: "0.8\\columnwidth" },
7236
7272
  ...defaultFloatMeta()
7237
7273
  };
7238
7274
  return insertDocument2BlockAfter(document2, afterBlockId, block);
@@ -7832,8 +7868,16 @@ function tableBlockLatex(block) {
7832
7868
  lines.push("\\end{table}");
7833
7869
  return lines.join("\n");
7834
7870
  }
7835
- function imageOptionsLatex(block) {
7836
- const entries = Object.entries(block.options);
7871
+ function remapImageWidthForColumns(value) {
7872
+ return value.replace(/\\textwidth\b/g, "\\columnwidth");
7873
+ }
7874
+ function imageOptionsLatex(block, constrainToColumn) {
7875
+ const entries = Object.entries(block.options).map(([key, value]) => {
7876
+ if (constrainToColumn && key === "width") {
7877
+ return [key, remapImageWidthForColumns(value)];
7878
+ }
7879
+ return [key, value];
7880
+ });
7837
7881
  if (entries.length === 0) {
7838
7882
  return "";
7839
7883
  }
@@ -7844,7 +7888,7 @@ function imageBlockLatex(block) {
7844
7888
  if (block.centered) {
7845
7889
  lines.push(" \\centering");
7846
7890
  }
7847
- lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
7891
+ lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
7848
7892
  lines.push(...floatCaptionLabelLines(block));
7849
7893
  lines.push("\\end{figure}");
7850
7894
  return lines.join("\n");
@@ -7874,11 +7918,11 @@ ${block.closing}`;
7874
7918
  function authorLatex(authors) {
7875
7919
  return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
7876
7920
  }
7877
- function articleMaketitlePreamble(meta) {
7921
+ function articleMaketitlePreamble(meta, twocolumn = false) {
7878
7922
  if (!document2HasMaketitle(meta)) {
7879
7923
  return "";
7880
7924
  }
7881
- const parts = [butexBasmalaTitlingPreamble()];
7925
+ const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
7882
7926
  if (meta.title.trim().length > 0) {
7883
7927
  parts.push(`\\title{${meta.title.trim()}}`);
7884
7928
  }
@@ -7904,21 +7948,22 @@ ${meta.abstract.trim()}
7904
7948
  }
7905
7949
  function document2Latex(document2, options = {}) {
7906
7950
  const meta = document2.meta ?? emptyDocument2Meta();
7951
+ const twocolumn = options.twocolumn === true;
7907
7952
  const front = articleFrontMatterLatex(meta);
7908
7953
  const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
7909
7954
  const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
7910
7955
  const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
7911
7956
  const wrapDocument = options.wrapDocument !== false;
7912
7957
  if (!wrapDocument) {
7913
- const metaPreamble = articleMaketitlePreamble(meta);
7958
+ const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
7914
7959
  return metaPreamble.length > 0 ? `${metaPreamble}
7915
7960
 
7916
7961
  ${body}` : body;
7917
7962
  }
7918
7963
  const preamble = getArabicXeLatexPreamble({
7919
7964
  digitsMapping: options.digitsMapping ?? "arabicdigits",
7920
- twocolumn: options.twocolumn === true
7921
- }) + "\n" + articleMaketitlePreamble(meta);
7965
+ twocolumn
7966
+ }) + "\n" + articleMaketitlePreamble(meta, twocolumn);
7922
7967
  return `${preamble}
7923
7968
  \\begin{document}
7924
7969
 
@@ -8563,6 +8608,8 @@ function ArticleMetaPanel({
8563
8608
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "butex-document2-widget__article-meta-fixed", dir: "rtl", children: [
8564
8609
  BUTEX_BASMALA_LINE1,
8565
8610
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
8611
+ BUTEX_BASMALA_LINE2,
8612
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
8566
8613
  BUTEX_BASMALA_SALAWAT
8567
8614
  ] }),
8568
8615
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-document2-widget__article-meta-grid", children: [