@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.
- package/README.md +1 -1
- package/dist/document2.d.mts +16 -7
- package/dist/document2.d.ts +16 -7
- package/dist/document2.js +66 -17
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +64 -17
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.js +64 -17
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +64 -17
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document2.mjs
CHANGED
|
@@ -35,9 +35,11 @@ function formatDigits(value, digitForm = "western") {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// src/document2/articleMeta.ts
|
|
38
|
-
var BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \
|
|
39
|
-
var
|
|
38
|
+
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";
|
|
39
|
+
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";
|
|
40
|
+
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";
|
|
40
41
|
var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
|
|
42
|
+
${BUTEX_BASMALA_LINE2}
|
|
41
43
|
${BUTEX_BASMALA_SALAWAT}`;
|
|
42
44
|
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
45
|
function escapeButexTextArg(text) {
|
|
@@ -51,26 +53,60 @@ function butexDiwaniDisplayLatex(text) {
|
|
|
51
53
|
${butexDiwaniDisplayTex(text)}
|
|
52
54
|
\\]`;
|
|
53
55
|
}
|
|
56
|
+
var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
|
|
54
57
|
function butexBasmalaDisplayTex() {
|
|
55
|
-
return
|
|
58
|
+
return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
|
|
56
59
|
}
|
|
57
60
|
function butexBasmalaDisplayLatex() {
|
|
58
61
|
return `\\[
|
|
59
62
|
${butexBasmalaDisplayTex()}
|
|
60
63
|
\\]`;
|
|
61
64
|
}
|
|
62
|
-
function
|
|
63
|
-
return
|
|
65
|
+
function butexInColumnMaketitleHook() {
|
|
66
|
+
return String.raw`\makeatletter
|
|
67
|
+
\renewcommand{\maketitle}{%
|
|
68
|
+
\par
|
|
69
|
+
\begingroup
|
|
70
|
+
\renewcommand\thefootnote{\@fnsymbol\c@footnote}%
|
|
71
|
+
\def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
|
|
72
|
+
\long\def\@makefntext##1{\parindent 1em\noindent
|
|
73
|
+
\hb@xt@1.8em{\hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
|
|
74
|
+
\@maketitle
|
|
75
|
+
\thispagestyle{plain}\@thanks
|
|
76
|
+
\endgroup
|
|
77
|
+
\setcounter{footnote}{0}%
|
|
78
|
+
\global\let\thanks\relax
|
|
79
|
+
\global\let\maketitle\relax
|
|
80
|
+
\global\let\@maketitle\relax
|
|
81
|
+
\global\let\@thanks\@empty
|
|
82
|
+
\global\let\@author\@empty
|
|
83
|
+
\global\let\@date\@empty
|
|
84
|
+
\global\let\@title\@empty
|
|
85
|
+
\global\let\title\relax
|
|
86
|
+
\global\let\author\relax
|
|
87
|
+
\global\let\date\relax
|
|
88
|
+
\global\let\and\relax
|
|
89
|
+
}
|
|
90
|
+
\makeatother`;
|
|
91
|
+
}
|
|
92
|
+
function butexBasmalaTitlingPreamble(options = {}) {
|
|
93
|
+
const lines = [
|
|
64
94
|
"\\usepackage{titling}",
|
|
65
95
|
"\\pretitle{%",
|
|
66
96
|
" \\begin{center}",
|
|
67
|
-
|
|
68
|
-
|
|
97
|
+
...BASMALA_LINES.map((line, index) => {
|
|
98
|
+
const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
|
|
99
|
+
return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
|
|
100
|
+
}),
|
|
69
101
|
" \\par\\vspace{1.5em}",
|
|
70
102
|
" \\LARGE",
|
|
71
103
|
"}",
|
|
72
104
|
"\\posttitle{\\par\\end{center}}"
|
|
73
|
-
]
|
|
105
|
+
];
|
|
106
|
+
if (options.twocolumn) {
|
|
107
|
+
lines.push(butexInColumnMaketitleHook());
|
|
108
|
+
}
|
|
109
|
+
return lines.join("\n");
|
|
74
110
|
}
|
|
75
111
|
var HIJRI_YEAR_MIN = 1400;
|
|
76
112
|
var HIJRI_YEAR_MAX = 1500;
|
|
@@ -3947,7 +3983,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
|
|
|
3947
3983
|
kind: "image",
|
|
3948
3984
|
command: "\\includegraphics",
|
|
3949
3985
|
value: src,
|
|
3950
|
-
options: { width: "0.8\\
|
|
3986
|
+
options: { width: "0.8\\columnwidth" },
|
|
3951
3987
|
...defaultFloatMeta()
|
|
3952
3988
|
};
|
|
3953
3989
|
return insertDocument2BlockAfter(document2, afterBlockId, block);
|
|
@@ -4552,8 +4588,16 @@ function tableBlockLatex(block) {
|
|
|
4552
4588
|
lines.push("\\end{table}");
|
|
4553
4589
|
return lines.join("\n");
|
|
4554
4590
|
}
|
|
4555
|
-
function
|
|
4556
|
-
|
|
4591
|
+
function remapImageWidthForColumns(value) {
|
|
4592
|
+
return value.replace(/\\textwidth\b/g, "\\columnwidth");
|
|
4593
|
+
}
|
|
4594
|
+
function imageOptionsLatex(block, constrainToColumn) {
|
|
4595
|
+
const entries = Object.entries(block.options).map(([key, value]) => {
|
|
4596
|
+
if (constrainToColumn && key === "width") {
|
|
4597
|
+
return [key, remapImageWidthForColumns(value)];
|
|
4598
|
+
}
|
|
4599
|
+
return [key, value];
|
|
4600
|
+
});
|
|
4557
4601
|
if (entries.length === 0) {
|
|
4558
4602
|
return "";
|
|
4559
4603
|
}
|
|
@@ -4564,7 +4608,7 @@ function imageBlockLatex(block) {
|
|
|
4564
4608
|
if (block.centered) {
|
|
4565
4609
|
lines.push(" \\centering");
|
|
4566
4610
|
}
|
|
4567
|
-
lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
|
|
4611
|
+
lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
|
|
4568
4612
|
lines.push(...floatCaptionLabelLines(block));
|
|
4569
4613
|
lines.push("\\end{figure}");
|
|
4570
4614
|
return lines.join("\n");
|
|
@@ -4594,11 +4638,11 @@ ${block.closing}`;
|
|
|
4594
4638
|
function authorLatex(authors) {
|
|
4595
4639
|
return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
|
|
4596
4640
|
}
|
|
4597
|
-
function articleMaketitlePreamble(meta) {
|
|
4641
|
+
function articleMaketitlePreamble(meta, twocolumn = false) {
|
|
4598
4642
|
if (!document2HasMaketitle(meta)) {
|
|
4599
4643
|
return "";
|
|
4600
4644
|
}
|
|
4601
|
-
const parts = [butexBasmalaTitlingPreamble()];
|
|
4645
|
+
const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
|
|
4602
4646
|
if (meta.title.trim().length > 0) {
|
|
4603
4647
|
parts.push(`\\title{${meta.title.trim()}}`);
|
|
4604
4648
|
}
|
|
@@ -4624,21 +4668,22 @@ ${meta.abstract.trim()}
|
|
|
4624
4668
|
}
|
|
4625
4669
|
function document2Latex(document2, options = {}) {
|
|
4626
4670
|
const meta = document2.meta ?? emptyDocument2Meta();
|
|
4671
|
+
const twocolumn = options.twocolumn === true;
|
|
4627
4672
|
const front = articleFrontMatterLatex(meta);
|
|
4628
4673
|
const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
|
|
4629
4674
|
const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
|
|
4630
4675
|
const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
|
|
4631
4676
|
const wrapDocument = options.wrapDocument !== false;
|
|
4632
4677
|
if (!wrapDocument) {
|
|
4633
|
-
const metaPreamble = articleMaketitlePreamble(meta);
|
|
4678
|
+
const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
|
|
4634
4679
|
return metaPreamble.length > 0 ? `${metaPreamble}
|
|
4635
4680
|
|
|
4636
4681
|
${body}` : body;
|
|
4637
4682
|
}
|
|
4638
4683
|
const preamble = getArabicXeLatexPreamble({
|
|
4639
4684
|
digitsMapping: options.digitsMapping ?? "arabicdigits",
|
|
4640
|
-
twocolumn
|
|
4641
|
-
}) + "\n" + articleMaketitlePreamble(meta);
|
|
4685
|
+
twocolumn
|
|
4686
|
+
}) + "\n" + articleMaketitlePreamble(meta, twocolumn);
|
|
4642
4687
|
return `${preamble}
|
|
4643
4688
|
\\begin{document}
|
|
4644
4689
|
|
|
@@ -4920,6 +4965,7 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
4920
4965
|
export {
|
|
4921
4966
|
BUTEX_BASMALA,
|
|
4922
4967
|
BUTEX_BASMALA_LINE1,
|
|
4968
|
+
BUTEX_BASMALA_LINE2,
|
|
4923
4969
|
BUTEX_BASMALA_SALAWAT,
|
|
4924
4970
|
BUTEX_CLOSING_HAMDALA,
|
|
4925
4971
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
@@ -4943,6 +4989,7 @@ export {
|
|
|
4943
4989
|
butexBasmalaTitlingPreamble,
|
|
4944
4990
|
butexDiwaniDisplayLatex,
|
|
4945
4991
|
butexDiwaniDisplayTex,
|
|
4992
|
+
butexInColumnMaketitleHook,
|
|
4946
4993
|
citeTokenLatex,
|
|
4947
4994
|
cloneDocument2Meta,
|
|
4948
4995
|
cloneDocument2Node,
|