@drghaliasri/butex 5.3.1 → 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/dist/document2.d.mts +96 -51
- package/dist/document2.d.ts +96 -51
- package/dist/document2.js +119 -10
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +109 -10
- 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 +809 -279
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +764 -234
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document2.mjs
CHANGED
|
@@ -268,6 +268,10 @@ function cloneDocument2Meta(meta) {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
// src/document2/citations.ts
|
|
271
|
+
var DEFAULT_REFERENCE_FIELD_SEPARATOR = "\u060C";
|
|
272
|
+
function normalizeReferenceFieldSeparator(value) {
|
|
273
|
+
return value === "," ? "," : DEFAULT_REFERENCE_FIELD_SEPARATOR;
|
|
274
|
+
}
|
|
271
275
|
function referenceNumberMap(references) {
|
|
272
276
|
const map = /* @__PURE__ */ new Map();
|
|
273
277
|
references.forEach((reference, index) => {
|
|
@@ -313,7 +317,8 @@ function referenceFromJson(json) {
|
|
|
313
317
|
title: typeof json.title === "string" ? json.title : "",
|
|
314
318
|
year: typeof json.year === "string" ? json.year : "",
|
|
315
319
|
url: typeof json.url === "string" ? json.url : "",
|
|
316
|
-
venue: typeof json.venue === "string" ? json.venue : ""
|
|
320
|
+
venue: typeof json.venue === "string" ? json.venue : "",
|
|
321
|
+
fieldSeparator: normalizeReferenceFieldSeparator(json.field_separator)
|
|
317
322
|
};
|
|
318
323
|
}
|
|
319
324
|
function createEmptyReference2(partial = {}) {
|
|
@@ -323,15 +328,33 @@ function createEmptyReference2(partial = {}) {
|
|
|
323
328
|
title: partial.title,
|
|
324
329
|
year: partial.year,
|
|
325
330
|
url: partial.url,
|
|
326
|
-
venue: partial.venue
|
|
331
|
+
venue: partial.venue,
|
|
332
|
+
field_separator: partial.field_separator
|
|
327
333
|
});
|
|
328
334
|
}
|
|
335
|
+
function bibliographyEntryBody(reference, separator = reference.fieldSeparator, options = {}) {
|
|
336
|
+
const year = options.digitForm !== void 0 ? formatDigits(reference.year, options.digitForm) : reference.year;
|
|
337
|
+
const parts = [reference.authors, reference.title, reference.venue, year].filter((part) => part.trim().length > 0);
|
|
338
|
+
return parts.join(`${separator} `);
|
|
339
|
+
}
|
|
329
340
|
function bibliographyEntryLatex(reference) {
|
|
330
|
-
const
|
|
331
|
-
const body = parts.join(", ");
|
|
341
|
+
const body = bibliographyEntryBody(reference);
|
|
332
342
|
const url = reference.url.trim().length > 0 ? ` \\url{${reference.url}}` : "";
|
|
333
343
|
return `\\bibitem{${reference.key}} ${body}${url}`.trim();
|
|
334
344
|
}
|
|
345
|
+
function absoluteHttpHref(url) {
|
|
346
|
+
const trimmed = url.trim();
|
|
347
|
+
if (trimmed.length === 0) {
|
|
348
|
+
return "";
|
|
349
|
+
}
|
|
350
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
351
|
+
return trimmed;
|
|
352
|
+
}
|
|
353
|
+
if (trimmed.startsWith("//")) {
|
|
354
|
+
return `https:${trimmed}`;
|
|
355
|
+
}
|
|
356
|
+
return `https://${trimmed}`;
|
|
357
|
+
}
|
|
335
358
|
|
|
336
359
|
// src/ast/commands/index.ts
|
|
337
360
|
function renderCommandCore(context) {
|
|
@@ -816,6 +839,23 @@ function labelNumberMap(document2) {
|
|
|
816
839
|
}
|
|
817
840
|
return map;
|
|
818
841
|
}
|
|
842
|
+
function formatFloatCaptionTitle(kind, number, options = {}) {
|
|
843
|
+
const locale = options.uiLocale ?? "ar";
|
|
844
|
+
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";
|
|
845
|
+
const digits = formatBibliographyNumber(number, {
|
|
846
|
+
documentDirection: options.documentDirection ?? (locale === "ar" ? "rtl" : "ltr"),
|
|
847
|
+
digitForm: options.digitForm ?? (locale === "ar" ? "arabicIndic" : "western")
|
|
848
|
+
});
|
|
849
|
+
return `${kindWord} ${digits}`;
|
|
850
|
+
}
|
|
851
|
+
function formatFloatCaptionPreview(title, caption, uiLocale = "ar") {
|
|
852
|
+
const trimmed = caption?.trim() ?? "";
|
|
853
|
+
if (trimmed.length === 0) {
|
|
854
|
+
return title;
|
|
855
|
+
}
|
|
856
|
+
const separator = uiLocale === "ar" ? ": " : ". ";
|
|
857
|
+
return `${title}${separator}${trimmed}`;
|
|
858
|
+
}
|
|
819
859
|
function formatRefLabel(keys, document2, refCommand, options = {}) {
|
|
820
860
|
const documentDirection = options.documentDirection ?? "rtl";
|
|
821
861
|
const digitForm = options.digitForm ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
|
|
@@ -1086,7 +1126,8 @@ function parseReferences(json) {
|
|
|
1086
1126
|
title: typeof entry.title === "string" ? entry.title : void 0,
|
|
1087
1127
|
year: typeof entry.year === "string" ? entry.year : void 0,
|
|
1088
1128
|
url: typeof entry.url === "string" ? entry.url : void 0,
|
|
1089
|
-
venue: typeof entry.venue === "string" ? entry.venue : void 0
|
|
1129
|
+
venue: typeof entry.venue === "string" ? entry.venue : void 0,
|
|
1130
|
+
field_separator: entry.field_separator === "," || entry.field_separator === "\u060C" ? entry.field_separator : void 0
|
|
1090
1131
|
})
|
|
1091
1132
|
);
|
|
1092
1133
|
}
|
|
@@ -4268,6 +4309,9 @@ function updateDocument2Reference(document2, referenceId, patch) {
|
|
|
4268
4309
|
if (typeof patch.venue === "string") {
|
|
4269
4310
|
reference.venue = patch.venue;
|
|
4270
4311
|
}
|
|
4312
|
+
if (patch.field_separator === "," || patch.field_separator === "\u060C") {
|
|
4313
|
+
reference.fieldSeparator = patch.field_separator;
|
|
4314
|
+
}
|
|
4271
4315
|
return next;
|
|
4272
4316
|
}
|
|
4273
4317
|
function removeDocument2Reference(document2, referenceId) {
|
|
@@ -4306,6 +4350,52 @@ function updateDocument2Meta(document2, patch) {
|
|
|
4306
4350
|
return next;
|
|
4307
4351
|
}
|
|
4308
4352
|
|
|
4353
|
+
// src/document2/keys.ts
|
|
4354
|
+
var DOCUMENT2_KEY_PATTERN = /^[\p{L}\p{M}0-9:._-]+$/u;
|
|
4355
|
+
function normalizeDocument2Key(key) {
|
|
4356
|
+
return key.normalize("NFC").trim();
|
|
4357
|
+
}
|
|
4358
|
+
function isValidDocument2Key(key) {
|
|
4359
|
+
const normalized = normalizeDocument2Key(key);
|
|
4360
|
+
return normalized.length > 0 && DOCUMENT2_KEY_PATTERN.test(normalized);
|
|
4361
|
+
}
|
|
4362
|
+
function isDuplicateDocument2Key(key, namespace) {
|
|
4363
|
+
const normalized = normalizeDocument2Key(key);
|
|
4364
|
+
if (normalized.length === 0) {
|
|
4365
|
+
return false;
|
|
4366
|
+
}
|
|
4367
|
+
for (const reference of namespace.references ?? []) {
|
|
4368
|
+
if (namespace.excludeReferenceId && reference.id === namespace.excludeReferenceId) {
|
|
4369
|
+
continue;
|
|
4370
|
+
}
|
|
4371
|
+
if (normalizeDocument2Key(reference.key) === normalized) {
|
|
4372
|
+
return true;
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
for (const label of namespace.labels ?? []) {
|
|
4376
|
+
if (namespace.excludeOwnerId && label.ownerId === namespace.excludeOwnerId) {
|
|
4377
|
+
continue;
|
|
4378
|
+
}
|
|
4379
|
+
if (normalizeDocument2Key(label.key) === normalized) {
|
|
4380
|
+
return true;
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
return false;
|
|
4384
|
+
}
|
|
4385
|
+
function document2KeyError(key, namespace = {}) {
|
|
4386
|
+
const normalized = normalizeDocument2Key(key);
|
|
4387
|
+
if (normalized.length === 0) {
|
|
4388
|
+
return "empty";
|
|
4389
|
+
}
|
|
4390
|
+
if (!DOCUMENT2_KEY_PATTERN.test(normalized)) {
|
|
4391
|
+
return "invalid";
|
|
4392
|
+
}
|
|
4393
|
+
if (isDuplicateDocument2Key(normalized, namespace)) {
|
|
4394
|
+
return "duplicate";
|
|
4395
|
+
}
|
|
4396
|
+
return null;
|
|
4397
|
+
}
|
|
4398
|
+
|
|
4309
4399
|
// src/document2/arabicPreamble.ts
|
|
4310
4400
|
function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
4311
4401
|
const classOptions = twocolumn ? "12pt,a4paper,notitlepage,twocolumn" : "12pt,a4paper,notitlepage";
|
|
@@ -4856,13 +4946,11 @@ function floatNumberLabel(document2, key, previewOptions) {
|
|
|
4856
4946
|
if (!hit || hit.kind !== "fig" && hit.kind !== "tab") {
|
|
4857
4947
|
return void 0;
|
|
4858
4948
|
}
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
const digits = formatBibliographyNumber(hit.number, {
|
|
4949
|
+
return formatFloatCaptionTitle(hit.kind, hit.number, {
|
|
4950
|
+
uiLocale: previewOptions.uiLocale ?? "ar",
|
|
4862
4951
|
documentDirection: previewOptions.documentDirection,
|
|
4863
4952
|
digitForm: previewOptions.digitForm
|
|
4864
4953
|
});
|
|
4865
|
-
return `${kindWord} ${digits}`;
|
|
4866
4954
|
}
|
|
4867
4955
|
function blockPreview(block, islands, output, equationSide, document2, previewOptions) {
|
|
4868
4956
|
if (block.kind === "textBlock") {
|
|
@@ -4917,7 +5005,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
4917
5005
|
title: reference.title,
|
|
4918
5006
|
year: reference.year,
|
|
4919
5007
|
url: reference.url,
|
|
4920
|
-
venue: reference.venue
|
|
5008
|
+
venue: reference.venue,
|
|
5009
|
+
fieldSeparator: reference.fieldSeparator
|
|
4921
5010
|
}))
|
|
4922
5011
|
};
|
|
4923
5012
|
}
|
|
@@ -4970,9 +5059,11 @@ export {
|
|
|
4970
5059
|
BUTEX_CLOSING_HAMDALA,
|
|
4971
5060
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
4972
5061
|
DEFAULT_HIJRI_DATE,
|
|
5062
|
+
DEFAULT_REFERENCE_FIELD_SEPARATOR,
|
|
4973
5063
|
HIJRI_MONTH_IDS,
|
|
4974
5064
|
HIJRI_YEAR_MAX,
|
|
4975
5065
|
HIJRI_YEAR_MIN,
|
|
5066
|
+
absoluteHttpHref,
|
|
4976
5067
|
addDocument2ImageBlock,
|
|
4977
5068
|
addDocument2ListBlock,
|
|
4978
5069
|
addDocument2ListItem,
|
|
@@ -4983,6 +5074,7 @@ export {
|
|
|
4983
5074
|
arabicXeLatexPreambleCmd,
|
|
4984
5075
|
arabicXeLatexPreambleFont,
|
|
4985
5076
|
arabicXeLatexPreamblePkg,
|
|
5077
|
+
bibliographyEntryBody,
|
|
4986
5078
|
bibliographyEntryLatex,
|
|
4987
5079
|
butexBasmalaDisplayLatex,
|
|
4988
5080
|
butexBasmalaDisplayTex,
|
|
@@ -5008,6 +5100,7 @@ export {
|
|
|
5008
5100
|
document2HasTitleStack,
|
|
5009
5101
|
document2HistoryCanRedo,
|
|
5010
5102
|
document2HistoryCanUndo,
|
|
5103
|
+
document2KeyError,
|
|
5011
5104
|
document2Latex,
|
|
5012
5105
|
document2Preview,
|
|
5013
5106
|
emptyBlockSelection,
|
|
@@ -5018,6 +5111,8 @@ export {
|
|
|
5018
5111
|
findFirstInlineField,
|
|
5019
5112
|
formatBibliographyNumber,
|
|
5020
5113
|
formatCiteLabel,
|
|
5114
|
+
formatFloatCaptionPreview,
|
|
5115
|
+
formatFloatCaptionTitle,
|
|
5021
5116
|
formatHijriDate,
|
|
5022
5117
|
formatRefLabel,
|
|
5023
5118
|
fromDocumentJson2,
|
|
@@ -5029,6 +5124,8 @@ export {
|
|
|
5029
5124
|
insertMathToken,
|
|
5030
5125
|
insertMathTokenAtCaret,
|
|
5031
5126
|
insertRefTokenAtCaret,
|
|
5127
|
+
isDuplicateDocument2Key,
|
|
5128
|
+
isValidDocument2Key,
|
|
5032
5129
|
labelNumberMap,
|
|
5033
5130
|
mathNodeFromArabicSession,
|
|
5034
5131
|
mathNodeFromSession,
|
|
@@ -5043,7 +5140,9 @@ export {
|
|
|
5043
5140
|
moveDocument2Reference,
|
|
5044
5141
|
normalizeBlockSelection,
|
|
5045
5142
|
normalizeDocument2HijriDate,
|
|
5143
|
+
normalizeDocument2Key,
|
|
5046
5144
|
normalizeDocument2Meta,
|
|
5145
|
+
normalizeReferenceFieldSeparator,
|
|
5047
5146
|
parseCiteKeys,
|
|
5048
5147
|
parseFloatMetaFromJson,
|
|
5049
5148
|
parseRefKeys,
|