@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.
- package/README.md +1 -1
- package/dist/document2.d.mts +20 -2
- package/dist/document2.d.ts +20 -2
- package/dist/document2.js +113 -18
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +106 -18
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.js +106 -19
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +106 -19
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react-document2.js
CHANGED
|
@@ -73,7 +73,12 @@ function formatDigits(value, digitForm = "western") {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// src/document2/articleMeta.ts
|
|
76
|
-
var
|
|
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";
|
|
79
|
+
var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
|
|
80
|
+
${BUTEX_BASMALA_LINE2}
|
|
81
|
+
${BUTEX_BASMALA_SALAWAT}`;
|
|
77
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";
|
|
78
83
|
function escapeButexTextArg(text) {
|
|
79
84
|
return text.replace(/\\/g, "\\textbackslash{}").replace(/[{}]/g, "\\$&");
|
|
@@ -86,6 +91,61 @@ function butexDiwaniDisplayLatex(text) {
|
|
|
86
91
|
${butexDiwaniDisplayTex(text)}
|
|
87
92
|
\\]`;
|
|
88
93
|
}
|
|
94
|
+
var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
|
|
95
|
+
function butexBasmalaDisplayTex() {
|
|
96
|
+
return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
|
|
97
|
+
}
|
|
98
|
+
function butexBasmalaDisplayLatex() {
|
|
99
|
+
return `\\[
|
|
100
|
+
${butexBasmalaDisplayTex()}
|
|
101
|
+
\\]`;
|
|
102
|
+
}
|
|
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 = [
|
|
132
|
+
"\\usepackage{titling}",
|
|
133
|
+
"\\pretitle{%",
|
|
134
|
+
" \\begin{center}",
|
|
135
|
+
...BASMALA_LINES.map((line, index) => {
|
|
136
|
+
const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
|
|
137
|
+
return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
|
|
138
|
+
}),
|
|
139
|
+
" \\par\\vspace{1.5em}",
|
|
140
|
+
" \\LARGE",
|
|
141
|
+
"}",
|
|
142
|
+
"\\posttitle{\\par\\end{center}}"
|
|
143
|
+
];
|
|
144
|
+
if (options.twocolumn) {
|
|
145
|
+
lines.push(butexInColumnMaketitleHook());
|
|
146
|
+
}
|
|
147
|
+
return lines.join("\n");
|
|
148
|
+
}
|
|
89
149
|
var HIJRI_YEAR_MIN = 1400;
|
|
90
150
|
var HIJRI_YEAR_MAX = 1500;
|
|
91
151
|
var HIJRI_MONTH_IDS = [
|
|
@@ -7208,7 +7268,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
|
|
|
7208
7268
|
kind: "image",
|
|
7209
7269
|
command: "\\includegraphics",
|
|
7210
7270
|
value: src,
|
|
7211
|
-
options: { width: "0.8\\
|
|
7271
|
+
options: { width: "0.8\\columnwidth" },
|
|
7212
7272
|
...defaultFloatMeta()
|
|
7213
7273
|
};
|
|
7214
7274
|
return insertDocument2BlockAfter(document2, afterBlockId, block);
|
|
@@ -7528,7 +7588,7 @@ function updateDocument2Meta(document2, patch) {
|
|
|
7528
7588
|
|
|
7529
7589
|
// src/document2/arabicPreamble.ts
|
|
7530
7590
|
function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
7531
|
-
const classOptions = twocolumn ? "12pt,a4paper,twocolumn" : "12pt,a4paper";
|
|
7591
|
+
const classOptions = twocolumn ? "12pt,a4paper,notitlepage,twocolumn" : "12pt,a4paper,notitlepage";
|
|
7532
7592
|
return `
|
|
7533
7593
|
\\documentclass[${classOptions}]{article}
|
|
7534
7594
|
` + String.raw`\usepackage{amsmath,amsfonts,amssymb,mathrsfs,tikz,fancyhdr, mathtools}
|
|
@@ -7808,8 +7868,16 @@ function tableBlockLatex(block) {
|
|
|
7808
7868
|
lines.push("\\end{table}");
|
|
7809
7869
|
return lines.join("\n");
|
|
7810
7870
|
}
|
|
7811
|
-
function
|
|
7812
|
-
|
|
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
|
+
});
|
|
7813
7881
|
if (entries.length === 0) {
|
|
7814
7882
|
return "";
|
|
7815
7883
|
}
|
|
@@ -7820,7 +7888,7 @@ function imageBlockLatex(block) {
|
|
|
7820
7888
|
if (block.centered) {
|
|
7821
7889
|
lines.push(" \\centering");
|
|
7822
7890
|
}
|
|
7823
|
-
lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
|
|
7891
|
+
lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
|
|
7824
7892
|
lines.push(...floatCaptionLabelLines(block));
|
|
7825
7893
|
lines.push("\\end{figure}");
|
|
7826
7894
|
return lines.join("\n");
|
|
@@ -7850,17 +7918,26 @@ ${block.closing}`;
|
|
|
7850
7918
|
function authorLatex(authors) {
|
|
7851
7919
|
return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
|
|
7852
7920
|
}
|
|
7921
|
+
function articleMaketitlePreamble(meta, twocolumn = false) {
|
|
7922
|
+
if (!document2HasMaketitle(meta)) {
|
|
7923
|
+
return "";
|
|
7924
|
+
}
|
|
7925
|
+
const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
|
|
7926
|
+
if (meta.title.trim().length > 0) {
|
|
7927
|
+
parts.push(`\\title{${meta.title.trim()}}`);
|
|
7928
|
+
}
|
|
7929
|
+
if (meta.authors.trim().length > 0) {
|
|
7930
|
+
parts.push(`\\author{${authorLatex(meta.authors)}}`);
|
|
7931
|
+
}
|
|
7932
|
+
parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "arabicIndic" })}}`);
|
|
7933
|
+
return parts.join("\n");
|
|
7934
|
+
}
|
|
7853
7935
|
function articleFrontMatterLatex(meta) {
|
|
7854
|
-
const parts = [
|
|
7936
|
+
const parts = [];
|
|
7855
7937
|
if (document2HasMaketitle(meta)) {
|
|
7856
|
-
if (meta.title.trim().length > 0) {
|
|
7857
|
-
parts.push(`\\title{${meta.title.trim()}}`);
|
|
7858
|
-
}
|
|
7859
|
-
if (meta.authors.trim().length > 0) {
|
|
7860
|
-
parts.push(`\\author{${authorLatex(meta.authors)}}`);
|
|
7861
|
-
}
|
|
7862
|
-
parts.push(`\\date{${formatHijriDate(meta.date, { locale: "ar", digitForm: "arabicIndic" })}}`);
|
|
7863
7938
|
parts.push("\\maketitle");
|
|
7939
|
+
} else {
|
|
7940
|
+
parts.push(butexBasmalaDisplayLatex());
|
|
7864
7941
|
}
|
|
7865
7942
|
if (document2HasAbstract(meta)) {
|
|
7866
7943
|
parts.push(`\\begin{abstract}
|
|
@@ -7871,18 +7948,22 @@ ${meta.abstract.trim()}
|
|
|
7871
7948
|
}
|
|
7872
7949
|
function document2Latex(document2, options = {}) {
|
|
7873
7950
|
const meta = document2.meta ?? emptyDocument2Meta();
|
|
7951
|
+
const twocolumn = options.twocolumn === true;
|
|
7874
7952
|
const front = articleFrontMatterLatex(meta);
|
|
7875
7953
|
const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
|
|
7876
7954
|
const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
|
|
7877
7955
|
const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
|
|
7878
7956
|
const wrapDocument = options.wrapDocument !== false;
|
|
7879
7957
|
if (!wrapDocument) {
|
|
7880
|
-
|
|
7958
|
+
const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
|
|
7959
|
+
return metaPreamble.length > 0 ? `${metaPreamble}
|
|
7960
|
+
|
|
7961
|
+
${body}` : body;
|
|
7881
7962
|
}
|
|
7882
7963
|
const preamble = getArabicXeLatexPreamble({
|
|
7883
7964
|
digitsMapping: options.digitsMapping ?? "arabicdigits",
|
|
7884
|
-
twocolumn
|
|
7885
|
-
});
|
|
7965
|
+
twocolumn
|
|
7966
|
+
}) + "\n" + articleMaketitlePreamble(meta, twocolumn);
|
|
7886
7967
|
return `${preamble}
|
|
7887
7968
|
\\begin{document}
|
|
7888
7969
|
|
|
@@ -8125,7 +8206,7 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
8125
8206
|
function articleChromePreview(document2, uiLocale, previewOptions) {
|
|
8126
8207
|
const meta = document2.meta ?? emptyDocument2Meta();
|
|
8127
8208
|
const blocks = [
|
|
8128
|
-
{ kind: "basmala", id: "article-basmala", text: BUTEX_BASMALA, tex:
|
|
8209
|
+
{ kind: "basmala", id: "article-basmala", text: BUTEX_BASMALA, tex: butexBasmalaDisplayTex() }
|
|
8129
8210
|
];
|
|
8130
8211
|
if (document2HasMaketitle(meta)) {
|
|
8131
8212
|
blocks.push({
|
|
@@ -8524,7 +8605,13 @@ function ArticleMetaPanel({
|
|
|
8524
8605
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: messages.articleMetaTitle }),
|
|
8525
8606
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "butex-document2-widget__article-meta-badge", children: messages.articleMetaBadge })
|
|
8526
8607
|
] }),
|
|
8527
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
8608
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "butex-document2-widget__article-meta-fixed", dir: "rtl", children: [
|
|
8609
|
+
BUTEX_BASMALA_LINE1,
|
|
8610
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
8611
|
+
BUTEX_BASMALA_LINE2,
|
|
8612
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
8613
|
+
BUTEX_BASMALA_SALAWAT
|
|
8614
|
+
] }),
|
|
8528
8615
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "butex-document2-widget__article-meta-grid", children: [
|
|
8529
8616
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "butex-document2-widget__article-meta-field", children: [
|
|
8530
8617
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: messages.articleTitle }),
|