@drghaliasri/butex 5.3.0 → 5.3.2
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 +111 -57
- package/dist/document2.d.ts +111 -57
- package/dist/document2.js +185 -27
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +173 -27
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.d.mts +72 -52
- package/dist/react-document2.d.ts +72 -52
- package/dist/react-document2.js +873 -296
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +828 -251
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document2.js
CHANGED
|
@@ -22,13 +22,16 @@ var document2_exports = {};
|
|
|
22
22
|
__export(document2_exports, {
|
|
23
23
|
BUTEX_BASMALA: () => BUTEX_BASMALA,
|
|
24
24
|
BUTEX_BASMALA_LINE1: () => BUTEX_BASMALA_LINE1,
|
|
25
|
+
BUTEX_BASMALA_LINE2: () => BUTEX_BASMALA_LINE2,
|
|
25
26
|
BUTEX_BASMALA_SALAWAT: () => BUTEX_BASMALA_SALAWAT,
|
|
26
27
|
BUTEX_CLOSING_HAMDALA: () => BUTEX_CLOSING_HAMDALA,
|
|
27
28
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH: () => DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
28
29
|
DEFAULT_HIJRI_DATE: () => DEFAULT_HIJRI_DATE,
|
|
30
|
+
DEFAULT_REFERENCE_FIELD_SEPARATOR: () => DEFAULT_REFERENCE_FIELD_SEPARATOR,
|
|
29
31
|
HIJRI_MONTH_IDS: () => HIJRI_MONTH_IDS,
|
|
30
32
|
HIJRI_YEAR_MAX: () => HIJRI_YEAR_MAX,
|
|
31
33
|
HIJRI_YEAR_MIN: () => HIJRI_YEAR_MIN,
|
|
34
|
+
absoluteHttpHref: () => absoluteHttpHref,
|
|
32
35
|
addDocument2ImageBlock: () => addDocument2ImageBlock,
|
|
33
36
|
addDocument2ListBlock: () => addDocument2ListBlock,
|
|
34
37
|
addDocument2ListItem: () => addDocument2ListItem,
|
|
@@ -39,12 +42,14 @@ __export(document2_exports, {
|
|
|
39
42
|
arabicXeLatexPreambleCmd: () => arabicXeLatexPreambleCmd,
|
|
40
43
|
arabicXeLatexPreambleFont: () => arabicXeLatexPreambleFont,
|
|
41
44
|
arabicXeLatexPreamblePkg: () => arabicXeLatexPreamblePkg,
|
|
45
|
+
bibliographyEntryBody: () => bibliographyEntryBody,
|
|
42
46
|
bibliographyEntryLatex: () => bibliographyEntryLatex,
|
|
43
47
|
butexBasmalaDisplayLatex: () => butexBasmalaDisplayLatex,
|
|
44
48
|
butexBasmalaDisplayTex: () => butexBasmalaDisplayTex,
|
|
45
49
|
butexBasmalaTitlingPreamble: () => butexBasmalaTitlingPreamble,
|
|
46
50
|
butexDiwaniDisplayLatex: () => butexDiwaniDisplayLatex,
|
|
47
51
|
butexDiwaniDisplayTex: () => butexDiwaniDisplayTex,
|
|
52
|
+
butexInColumnMaketitleHook: () => butexInColumnMaketitleHook,
|
|
48
53
|
citeTokenLatex: () => citeTokenLatex,
|
|
49
54
|
cloneDocument2Meta: () => cloneDocument2Meta,
|
|
50
55
|
cloneDocument2Node: () => cloneDocument2Node,
|
|
@@ -63,6 +68,7 @@ __export(document2_exports, {
|
|
|
63
68
|
document2HasTitleStack: () => document2HasTitleStack,
|
|
64
69
|
document2HistoryCanRedo: () => document2HistoryCanRedo,
|
|
65
70
|
document2HistoryCanUndo: () => document2HistoryCanUndo,
|
|
71
|
+
document2KeyError: () => document2KeyError,
|
|
66
72
|
document2Latex: () => document2Latex,
|
|
67
73
|
document2Preview: () => document2Preview,
|
|
68
74
|
emptyBlockSelection: () => emptyBlockSelection,
|
|
@@ -73,6 +79,8 @@ __export(document2_exports, {
|
|
|
73
79
|
findFirstInlineField: () => findFirstInlineField,
|
|
74
80
|
formatBibliographyNumber: () => formatBibliographyNumber,
|
|
75
81
|
formatCiteLabel: () => formatCiteLabel,
|
|
82
|
+
formatFloatCaptionPreview: () => formatFloatCaptionPreview,
|
|
83
|
+
formatFloatCaptionTitle: () => formatFloatCaptionTitle,
|
|
76
84
|
formatHijriDate: () => formatHijriDate,
|
|
77
85
|
formatRefLabel: () => formatRefLabel,
|
|
78
86
|
fromDocumentJson2: () => fromDocumentJson2,
|
|
@@ -84,6 +92,8 @@ __export(document2_exports, {
|
|
|
84
92
|
insertMathToken: () => insertMathToken,
|
|
85
93
|
insertMathTokenAtCaret: () => insertMathTokenAtCaret,
|
|
86
94
|
insertRefTokenAtCaret: () => insertRefTokenAtCaret,
|
|
95
|
+
isDuplicateDocument2Key: () => isDuplicateDocument2Key,
|
|
96
|
+
isValidDocument2Key: () => isValidDocument2Key,
|
|
87
97
|
labelNumberMap: () => labelNumberMap,
|
|
88
98
|
mathNodeFromArabicSession: () => mathNodeFromArabicSession,
|
|
89
99
|
mathNodeFromSession: () => mathNodeFromSession,
|
|
@@ -98,7 +108,9 @@ __export(document2_exports, {
|
|
|
98
108
|
moveDocument2Reference: () => moveDocument2Reference,
|
|
99
109
|
normalizeBlockSelection: () => normalizeBlockSelection,
|
|
100
110
|
normalizeDocument2HijriDate: () => normalizeDocument2HijriDate,
|
|
111
|
+
normalizeDocument2Key: () => normalizeDocument2Key,
|
|
101
112
|
normalizeDocument2Meta: () => normalizeDocument2Meta,
|
|
113
|
+
normalizeReferenceFieldSeparator: () => normalizeReferenceFieldSeparator,
|
|
102
114
|
parseCiteKeys: () => parseCiteKeys,
|
|
103
115
|
parseFloatMetaFromJson: () => parseFloatMetaFromJson,
|
|
104
116
|
parseRefKeys: () => parseRefKeys,
|
|
@@ -171,9 +183,11 @@ function formatDigits(value, digitForm = "western") {
|
|
|
171
183
|
}
|
|
172
184
|
|
|
173
185
|
// src/document2/articleMeta.ts
|
|
174
|
-
var BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \
|
|
175
|
-
var
|
|
186
|
+
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";
|
|
187
|
+
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";
|
|
188
|
+
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";
|
|
176
189
|
var BUTEX_BASMALA = `${BUTEX_BASMALA_LINE1}
|
|
190
|
+
${BUTEX_BASMALA_LINE2}
|
|
177
191
|
${BUTEX_BASMALA_SALAWAT}`;
|
|
178
192
|
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";
|
|
179
193
|
function escapeButexTextArg(text) {
|
|
@@ -187,26 +201,60 @@ function butexDiwaniDisplayLatex(text) {
|
|
|
187
201
|
${butexDiwaniDisplayTex(text)}
|
|
188
202
|
\\]`;
|
|
189
203
|
}
|
|
204
|
+
var BASMALA_LINES = [BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT];
|
|
190
205
|
function butexBasmalaDisplayTex() {
|
|
191
|
-
return
|
|
206
|
+
return BASMALA_LINES.map((line) => butexDiwaniDisplayTex(line)).join(" \\\\ ");
|
|
192
207
|
}
|
|
193
208
|
function butexBasmalaDisplayLatex() {
|
|
194
209
|
return `\\[
|
|
195
210
|
${butexBasmalaDisplayTex()}
|
|
196
211
|
\\]`;
|
|
197
212
|
}
|
|
198
|
-
function
|
|
199
|
-
return
|
|
213
|
+
function butexInColumnMaketitleHook() {
|
|
214
|
+
return String.raw`\makeatletter
|
|
215
|
+
\renewcommand{\maketitle}{%
|
|
216
|
+
\par
|
|
217
|
+
\begingroup
|
|
218
|
+
\renewcommand\thefootnote{\@fnsymbol\c@footnote}%
|
|
219
|
+
\def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%
|
|
220
|
+
\long\def\@makefntext##1{\parindent 1em\noindent
|
|
221
|
+
\hb@xt@1.8em{\hss\@textsuperscript{\normalfont\@thefnmark}}##1}%
|
|
222
|
+
\@maketitle
|
|
223
|
+
\thispagestyle{plain}\@thanks
|
|
224
|
+
\endgroup
|
|
225
|
+
\setcounter{footnote}{0}%
|
|
226
|
+
\global\let\thanks\relax
|
|
227
|
+
\global\let\maketitle\relax
|
|
228
|
+
\global\let\@maketitle\relax
|
|
229
|
+
\global\let\@thanks\@empty
|
|
230
|
+
\global\let\@author\@empty
|
|
231
|
+
\global\let\@date\@empty
|
|
232
|
+
\global\let\@title\@empty
|
|
233
|
+
\global\let\title\relax
|
|
234
|
+
\global\let\author\relax
|
|
235
|
+
\global\let\date\relax
|
|
236
|
+
\global\let\and\relax
|
|
237
|
+
}
|
|
238
|
+
\makeatother`;
|
|
239
|
+
}
|
|
240
|
+
function butexBasmalaTitlingPreamble(options = {}) {
|
|
241
|
+
const lines = [
|
|
200
242
|
"\\usepackage{titling}",
|
|
201
243
|
"\\pretitle{%",
|
|
202
244
|
" \\begin{center}",
|
|
203
|
-
|
|
204
|
-
|
|
245
|
+
...BASMALA_LINES.map((line, index) => {
|
|
246
|
+
const suffix = index < BASMALA_LINES.length - 1 ? "\\\\" : "";
|
|
247
|
+
return ` ${butexDiwaniDisplayTex(line)}${suffix}`;
|
|
248
|
+
}),
|
|
205
249
|
" \\par\\vspace{1.5em}",
|
|
206
250
|
" \\LARGE",
|
|
207
251
|
"}",
|
|
208
252
|
"\\posttitle{\\par\\end{center}}"
|
|
209
|
-
]
|
|
253
|
+
];
|
|
254
|
+
if (options.twocolumn) {
|
|
255
|
+
lines.push(butexInColumnMaketitleHook());
|
|
256
|
+
}
|
|
257
|
+
return lines.join("\n");
|
|
210
258
|
}
|
|
211
259
|
var HIJRI_YEAR_MIN = 1400;
|
|
212
260
|
var HIJRI_YEAR_MAX = 1500;
|
|
@@ -368,6 +416,10 @@ function cloneDocument2Meta(meta) {
|
|
|
368
416
|
}
|
|
369
417
|
|
|
370
418
|
// src/document2/citations.ts
|
|
419
|
+
var DEFAULT_REFERENCE_FIELD_SEPARATOR = "\u060C";
|
|
420
|
+
function normalizeReferenceFieldSeparator(value) {
|
|
421
|
+
return value === "," ? "," : DEFAULT_REFERENCE_FIELD_SEPARATOR;
|
|
422
|
+
}
|
|
371
423
|
function referenceNumberMap(references) {
|
|
372
424
|
const map = /* @__PURE__ */ new Map();
|
|
373
425
|
references.forEach((reference, index) => {
|
|
@@ -413,7 +465,8 @@ function referenceFromJson(json) {
|
|
|
413
465
|
title: typeof json.title === "string" ? json.title : "",
|
|
414
466
|
year: typeof json.year === "string" ? json.year : "",
|
|
415
467
|
url: typeof json.url === "string" ? json.url : "",
|
|
416
|
-
venue: typeof json.venue === "string" ? json.venue : ""
|
|
468
|
+
venue: typeof json.venue === "string" ? json.venue : "",
|
|
469
|
+
fieldSeparator: normalizeReferenceFieldSeparator(json.field_separator)
|
|
417
470
|
};
|
|
418
471
|
}
|
|
419
472
|
function createEmptyReference2(partial = {}) {
|
|
@@ -423,15 +476,33 @@ function createEmptyReference2(partial = {}) {
|
|
|
423
476
|
title: partial.title,
|
|
424
477
|
year: partial.year,
|
|
425
478
|
url: partial.url,
|
|
426
|
-
venue: partial.venue
|
|
479
|
+
venue: partial.venue,
|
|
480
|
+
field_separator: partial.field_separator
|
|
427
481
|
});
|
|
428
482
|
}
|
|
483
|
+
function bibliographyEntryBody(reference, separator = reference.fieldSeparator, options = {}) {
|
|
484
|
+
const year = options.digitForm !== void 0 ? formatDigits(reference.year, options.digitForm) : reference.year;
|
|
485
|
+
const parts = [reference.authors, reference.title, reference.venue, year].filter((part) => part.trim().length > 0);
|
|
486
|
+
return parts.join(`${separator} `);
|
|
487
|
+
}
|
|
429
488
|
function bibliographyEntryLatex(reference) {
|
|
430
|
-
const
|
|
431
|
-
const body = parts.join(", ");
|
|
489
|
+
const body = bibliographyEntryBody(reference);
|
|
432
490
|
const url = reference.url.trim().length > 0 ? ` \\url{${reference.url}}` : "";
|
|
433
491
|
return `\\bibitem{${reference.key}} ${body}${url}`.trim();
|
|
434
492
|
}
|
|
493
|
+
function absoluteHttpHref(url) {
|
|
494
|
+
const trimmed = url.trim();
|
|
495
|
+
if (trimmed.length === 0) {
|
|
496
|
+
return "";
|
|
497
|
+
}
|
|
498
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
499
|
+
return trimmed;
|
|
500
|
+
}
|
|
501
|
+
if (trimmed.startsWith("//")) {
|
|
502
|
+
return `https:${trimmed}`;
|
|
503
|
+
}
|
|
504
|
+
return `https://${trimmed}`;
|
|
505
|
+
}
|
|
435
506
|
|
|
436
507
|
// src/ast/commands/index.ts
|
|
437
508
|
function renderCommandCore(context) {
|
|
@@ -916,6 +987,23 @@ function labelNumberMap(document2) {
|
|
|
916
987
|
}
|
|
917
988
|
return map;
|
|
918
989
|
}
|
|
990
|
+
function formatFloatCaptionTitle(kind, number, options = {}) {
|
|
991
|
+
const locale = options.uiLocale ?? "ar";
|
|
992
|
+
const kindWord = kind === "fig" ? locale === "ar" ? "\u0627\u0644\u0634\u0643\u0644" : "Figure" : kind === "tab" ? locale === "ar" ? "\u0627\u0644\u062C\u062F\u0648\u0644" : "Table" : locale === "ar" ? "\u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" : "Equation";
|
|
993
|
+
const digits = formatBibliographyNumber(number, {
|
|
994
|
+
documentDirection: options.documentDirection ?? (locale === "ar" ? "rtl" : "ltr"),
|
|
995
|
+
digitForm: options.digitForm ?? (locale === "ar" ? "arabicIndic" : "western")
|
|
996
|
+
});
|
|
997
|
+
return `${kindWord} ${digits}`;
|
|
998
|
+
}
|
|
999
|
+
function formatFloatCaptionPreview(title, caption, uiLocale = "ar") {
|
|
1000
|
+
const trimmed = caption?.trim() ?? "";
|
|
1001
|
+
if (trimmed.length === 0) {
|
|
1002
|
+
return title;
|
|
1003
|
+
}
|
|
1004
|
+
const separator = uiLocale === "ar" ? ": " : ". ";
|
|
1005
|
+
return `${title}${separator}${trimmed}`;
|
|
1006
|
+
}
|
|
919
1007
|
function formatRefLabel(keys, document2, refCommand, options = {}) {
|
|
920
1008
|
const documentDirection = options.documentDirection ?? "rtl";
|
|
921
1009
|
const digitForm = options.digitForm ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
|
|
@@ -1186,7 +1274,8 @@ function parseReferences(json) {
|
|
|
1186
1274
|
title: typeof entry.title === "string" ? entry.title : void 0,
|
|
1187
1275
|
year: typeof entry.year === "string" ? entry.year : void 0,
|
|
1188
1276
|
url: typeof entry.url === "string" ? entry.url : void 0,
|
|
1189
|
-
venue: typeof entry.venue === "string" ? entry.venue : void 0
|
|
1277
|
+
venue: typeof entry.venue === "string" ? entry.venue : void 0,
|
|
1278
|
+
field_separator: entry.field_separator === "," || entry.field_separator === "\u060C" ? entry.field_separator : void 0
|
|
1190
1279
|
})
|
|
1191
1280
|
);
|
|
1192
1281
|
}
|
|
@@ -4083,7 +4172,7 @@ function addDocument2ImageBlock(document2, src = "", afterBlockId) {
|
|
|
4083
4172
|
kind: "image",
|
|
4084
4173
|
command: "\\includegraphics",
|
|
4085
4174
|
value: src,
|
|
4086
|
-
options: { width: "0.8\\
|
|
4175
|
+
options: { width: "0.8\\columnwidth" },
|
|
4087
4176
|
...defaultFloatMeta()
|
|
4088
4177
|
};
|
|
4089
4178
|
return insertDocument2BlockAfter(document2, afterBlockId, block);
|
|
@@ -4368,6 +4457,9 @@ function updateDocument2Reference(document2, referenceId, patch) {
|
|
|
4368
4457
|
if (typeof patch.venue === "string") {
|
|
4369
4458
|
reference.venue = patch.venue;
|
|
4370
4459
|
}
|
|
4460
|
+
if (patch.field_separator === "," || patch.field_separator === "\u060C") {
|
|
4461
|
+
reference.fieldSeparator = patch.field_separator;
|
|
4462
|
+
}
|
|
4371
4463
|
return next;
|
|
4372
4464
|
}
|
|
4373
4465
|
function removeDocument2Reference(document2, referenceId) {
|
|
@@ -4406,6 +4498,52 @@ function updateDocument2Meta(document2, patch) {
|
|
|
4406
4498
|
return next;
|
|
4407
4499
|
}
|
|
4408
4500
|
|
|
4501
|
+
// src/document2/keys.ts
|
|
4502
|
+
var DOCUMENT2_KEY_PATTERN = /^[\p{L}\p{M}0-9:._-]+$/u;
|
|
4503
|
+
function normalizeDocument2Key(key) {
|
|
4504
|
+
return key.normalize("NFC").trim();
|
|
4505
|
+
}
|
|
4506
|
+
function isValidDocument2Key(key) {
|
|
4507
|
+
const normalized = normalizeDocument2Key(key);
|
|
4508
|
+
return normalized.length > 0 && DOCUMENT2_KEY_PATTERN.test(normalized);
|
|
4509
|
+
}
|
|
4510
|
+
function isDuplicateDocument2Key(key, namespace) {
|
|
4511
|
+
const normalized = normalizeDocument2Key(key);
|
|
4512
|
+
if (normalized.length === 0) {
|
|
4513
|
+
return false;
|
|
4514
|
+
}
|
|
4515
|
+
for (const reference of namespace.references ?? []) {
|
|
4516
|
+
if (namespace.excludeReferenceId && reference.id === namespace.excludeReferenceId) {
|
|
4517
|
+
continue;
|
|
4518
|
+
}
|
|
4519
|
+
if (normalizeDocument2Key(reference.key) === normalized) {
|
|
4520
|
+
return true;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
for (const label of namespace.labels ?? []) {
|
|
4524
|
+
if (namespace.excludeOwnerId && label.ownerId === namespace.excludeOwnerId) {
|
|
4525
|
+
continue;
|
|
4526
|
+
}
|
|
4527
|
+
if (normalizeDocument2Key(label.key) === normalized) {
|
|
4528
|
+
return true;
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
return false;
|
|
4532
|
+
}
|
|
4533
|
+
function document2KeyError(key, namespace = {}) {
|
|
4534
|
+
const normalized = normalizeDocument2Key(key);
|
|
4535
|
+
if (normalized.length === 0) {
|
|
4536
|
+
return "empty";
|
|
4537
|
+
}
|
|
4538
|
+
if (!DOCUMENT2_KEY_PATTERN.test(normalized)) {
|
|
4539
|
+
return "invalid";
|
|
4540
|
+
}
|
|
4541
|
+
if (isDuplicateDocument2Key(normalized, namespace)) {
|
|
4542
|
+
return "duplicate";
|
|
4543
|
+
}
|
|
4544
|
+
return null;
|
|
4545
|
+
}
|
|
4546
|
+
|
|
4409
4547
|
// src/document2/arabicPreamble.ts
|
|
4410
4548
|
function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
4411
4549
|
const classOptions = twocolumn ? "12pt,a4paper,notitlepage,twocolumn" : "12pt,a4paper,notitlepage";
|
|
@@ -4688,8 +4826,16 @@ function tableBlockLatex(block) {
|
|
|
4688
4826
|
lines.push("\\end{table}");
|
|
4689
4827
|
return lines.join("\n");
|
|
4690
4828
|
}
|
|
4691
|
-
function
|
|
4692
|
-
|
|
4829
|
+
function remapImageWidthForColumns(value) {
|
|
4830
|
+
return value.replace(/\\textwidth\b/g, "\\columnwidth");
|
|
4831
|
+
}
|
|
4832
|
+
function imageOptionsLatex(block, constrainToColumn) {
|
|
4833
|
+
const entries = Object.entries(block.options).map(([key, value]) => {
|
|
4834
|
+
if (constrainToColumn && key === "width") {
|
|
4835
|
+
return [key, remapImageWidthForColumns(value)];
|
|
4836
|
+
}
|
|
4837
|
+
return [key, value];
|
|
4838
|
+
});
|
|
4693
4839
|
if (entries.length === 0) {
|
|
4694
4840
|
return "";
|
|
4695
4841
|
}
|
|
@@ -4700,7 +4846,7 @@ function imageBlockLatex(block) {
|
|
|
4700
4846
|
if (block.centered) {
|
|
4701
4847
|
lines.push(" \\centering");
|
|
4702
4848
|
}
|
|
4703
|
-
lines.push(` ${block.command}${imageOptionsLatex(block)}{${block.value}}`);
|
|
4849
|
+
lines.push(` ${block.command}${imageOptionsLatex(block, true)}{${block.value}}`);
|
|
4704
4850
|
lines.push(...floatCaptionLabelLines(block));
|
|
4705
4851
|
lines.push("\\end{figure}");
|
|
4706
4852
|
return lines.join("\n");
|
|
@@ -4730,11 +4876,11 @@ ${block.closing}`;
|
|
|
4730
4876
|
function authorLatex(authors) {
|
|
4731
4877
|
return authors.split(/\n+/).map((line) => line.trim()).filter((line) => line.length > 0).join(" \\\\ ");
|
|
4732
4878
|
}
|
|
4733
|
-
function articleMaketitlePreamble(meta) {
|
|
4879
|
+
function articleMaketitlePreamble(meta, twocolumn = false) {
|
|
4734
4880
|
if (!document2HasMaketitle(meta)) {
|
|
4735
4881
|
return "";
|
|
4736
4882
|
}
|
|
4737
|
-
const parts = [butexBasmalaTitlingPreamble()];
|
|
4883
|
+
const parts = [butexBasmalaTitlingPreamble({ twocolumn })];
|
|
4738
4884
|
if (meta.title.trim().length > 0) {
|
|
4739
4885
|
parts.push(`\\title{${meta.title.trim()}}`);
|
|
4740
4886
|
}
|
|
@@ -4760,21 +4906,22 @@ ${meta.abstract.trim()}
|
|
|
4760
4906
|
}
|
|
4761
4907
|
function document2Latex(document2, options = {}) {
|
|
4762
4908
|
const meta = document2.meta ?? emptyDocument2Meta();
|
|
4909
|
+
const twocolumn = options.twocolumn === true;
|
|
4763
4910
|
const front = articleFrontMatterLatex(meta);
|
|
4764
4911
|
const bodyBlocks = document2.blocks.map((block) => blockLatex(block, document2.references));
|
|
4765
4912
|
const closing = butexDiwaniDisplayLatex(BUTEX_CLOSING_HAMDALA);
|
|
4766
4913
|
const body = [...front, ...bodyBlocks, closing].filter((part) => part.length > 0).join("\n\n");
|
|
4767
4914
|
const wrapDocument = options.wrapDocument !== false;
|
|
4768
4915
|
if (!wrapDocument) {
|
|
4769
|
-
const metaPreamble = articleMaketitlePreamble(meta);
|
|
4916
|
+
const metaPreamble = articleMaketitlePreamble(meta, twocolumn);
|
|
4770
4917
|
return metaPreamble.length > 0 ? `${metaPreamble}
|
|
4771
4918
|
|
|
4772
4919
|
${body}` : body;
|
|
4773
4920
|
}
|
|
4774
4921
|
const preamble = getArabicXeLatexPreamble({
|
|
4775
4922
|
digitsMapping: options.digitsMapping ?? "arabicdigits",
|
|
4776
|
-
twocolumn
|
|
4777
|
-
}) + "\n" + articleMaketitlePreamble(meta);
|
|
4923
|
+
twocolumn
|
|
4924
|
+
}) + "\n" + articleMaketitlePreamble(meta, twocolumn);
|
|
4778
4925
|
return `${preamble}
|
|
4779
4926
|
\\begin{document}
|
|
4780
4927
|
|
|
@@ -4947,13 +5094,11 @@ function floatNumberLabel(document2, key, previewOptions) {
|
|
|
4947
5094
|
if (!hit || hit.kind !== "fig" && hit.kind !== "tab") {
|
|
4948
5095
|
return void 0;
|
|
4949
5096
|
}
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
const digits = formatBibliographyNumber(hit.number, {
|
|
5097
|
+
return formatFloatCaptionTitle(hit.kind, hit.number, {
|
|
5098
|
+
uiLocale: previewOptions.uiLocale ?? "ar",
|
|
4953
5099
|
documentDirection: previewOptions.documentDirection,
|
|
4954
5100
|
digitForm: previewOptions.digitForm
|
|
4955
5101
|
});
|
|
4956
|
-
return `${kindWord} ${digits}`;
|
|
4957
5102
|
}
|
|
4958
5103
|
function blockPreview(block, islands, output, equationSide, document2, previewOptions) {
|
|
4959
5104
|
if (block.kind === "textBlock") {
|
|
@@ -5008,7 +5153,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
5008
5153
|
title: reference.title,
|
|
5009
5154
|
year: reference.year,
|
|
5010
5155
|
url: reference.url,
|
|
5011
|
-
venue: reference.venue
|
|
5156
|
+
venue: reference.venue,
|
|
5157
|
+
fieldSeparator: reference.fieldSeparator
|
|
5012
5158
|
}))
|
|
5013
5159
|
};
|
|
5014
5160
|
}
|
|
@@ -5057,13 +5203,16 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5057
5203
|
0 && (module.exports = {
|
|
5058
5204
|
BUTEX_BASMALA,
|
|
5059
5205
|
BUTEX_BASMALA_LINE1,
|
|
5206
|
+
BUTEX_BASMALA_LINE2,
|
|
5060
5207
|
BUTEX_BASMALA_SALAWAT,
|
|
5061
5208
|
BUTEX_CLOSING_HAMDALA,
|
|
5062
5209
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
5063
5210
|
DEFAULT_HIJRI_DATE,
|
|
5211
|
+
DEFAULT_REFERENCE_FIELD_SEPARATOR,
|
|
5064
5212
|
HIJRI_MONTH_IDS,
|
|
5065
5213
|
HIJRI_YEAR_MAX,
|
|
5066
5214
|
HIJRI_YEAR_MIN,
|
|
5215
|
+
absoluteHttpHref,
|
|
5067
5216
|
addDocument2ImageBlock,
|
|
5068
5217
|
addDocument2ListBlock,
|
|
5069
5218
|
addDocument2ListItem,
|
|
@@ -5074,12 +5223,14 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5074
5223
|
arabicXeLatexPreambleCmd,
|
|
5075
5224
|
arabicXeLatexPreambleFont,
|
|
5076
5225
|
arabicXeLatexPreamblePkg,
|
|
5226
|
+
bibliographyEntryBody,
|
|
5077
5227
|
bibliographyEntryLatex,
|
|
5078
5228
|
butexBasmalaDisplayLatex,
|
|
5079
5229
|
butexBasmalaDisplayTex,
|
|
5080
5230
|
butexBasmalaTitlingPreamble,
|
|
5081
5231
|
butexDiwaniDisplayLatex,
|
|
5082
5232
|
butexDiwaniDisplayTex,
|
|
5233
|
+
butexInColumnMaketitleHook,
|
|
5083
5234
|
citeTokenLatex,
|
|
5084
5235
|
cloneDocument2Meta,
|
|
5085
5236
|
cloneDocument2Node,
|
|
@@ -5098,6 +5249,7 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5098
5249
|
document2HasTitleStack,
|
|
5099
5250
|
document2HistoryCanRedo,
|
|
5100
5251
|
document2HistoryCanUndo,
|
|
5252
|
+
document2KeyError,
|
|
5101
5253
|
document2Latex,
|
|
5102
5254
|
document2Preview,
|
|
5103
5255
|
emptyBlockSelection,
|
|
@@ -5108,6 +5260,8 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5108
5260
|
findFirstInlineField,
|
|
5109
5261
|
formatBibliographyNumber,
|
|
5110
5262
|
formatCiteLabel,
|
|
5263
|
+
formatFloatCaptionPreview,
|
|
5264
|
+
formatFloatCaptionTitle,
|
|
5111
5265
|
formatHijriDate,
|
|
5112
5266
|
formatRefLabel,
|
|
5113
5267
|
fromDocumentJson2,
|
|
@@ -5119,6 +5273,8 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5119
5273
|
insertMathToken,
|
|
5120
5274
|
insertMathTokenAtCaret,
|
|
5121
5275
|
insertRefTokenAtCaret,
|
|
5276
|
+
isDuplicateDocument2Key,
|
|
5277
|
+
isValidDocument2Key,
|
|
5122
5278
|
labelNumberMap,
|
|
5123
5279
|
mathNodeFromArabicSession,
|
|
5124
5280
|
mathNodeFromSession,
|
|
@@ -5133,7 +5289,9 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5133
5289
|
moveDocument2Reference,
|
|
5134
5290
|
normalizeBlockSelection,
|
|
5135
5291
|
normalizeDocument2HijriDate,
|
|
5292
|
+
normalizeDocument2Key,
|
|
5136
5293
|
normalizeDocument2Meta,
|
|
5294
|
+
normalizeReferenceFieldSeparator,
|
|
5137
5295
|
parseCiteKeys,
|
|
5138
5296
|
parseFloatMetaFromJson,
|
|
5139
5297
|
parseRefKeys,
|