@drghaliasri/butex 8.1.3 → 8.1.5
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/book.d.mts +1 -0
- package/dist/book.d.ts +1 -0
- package/dist/book.js +17 -1
- package/dist/book.js.map +1 -1
- package/dist/book.mjs +17 -1
- package/dist/book.mjs.map +1 -1
- package/dist/document-cli.js +16 -1
- package/dist/document-cli.js.map +1 -1
- package/dist/document.d.mts +1 -0
- package/dist/document.d.ts +1 -0
- package/dist/document.js +10 -2
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +10 -2
- package/dist/document.mjs.map +1 -1
- package/dist/react-book.d.mts +1 -0
- package/dist/react-book.d.ts +1 -0
- package/dist/react-book.js +10 -2
- package/dist/react-book.js.map +1 -1
- package/dist/react-book.mjs +10 -2
- package/dist/react-book.mjs.map +1 -1
- package/dist/react-document-preview.d.mts +1 -0
- package/dist/react-document-preview.d.ts +1 -0
- package/dist/react-document-preview.js +10 -2
- package/dist/react-document-preview.js.map +1 -1
- package/dist/react-document-preview.mjs +10 -2
- package/dist/react-document-preview.mjs.map +1 -1
- package/dist/react-document.d.mts +1 -0
- package/dist/react-document.d.ts +1 -0
- package/dist/react-document.js +10 -2
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +10 -2
- package/dist/react-document.mjs.map +1 -1
- package/package.json +1 -1
package/dist/book.d.mts
CHANGED
|
@@ -276,6 +276,7 @@ type DocumentBookTarget = {
|
|
|
276
276
|
kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
|
|
277
277
|
caption?: string;
|
|
278
278
|
displayLabel?: string;
|
|
279
|
+
ordinal?: string;
|
|
279
280
|
manualKey?: string;
|
|
280
281
|
};
|
|
281
282
|
type DocumentBookContext = {
|
package/dist/book.d.ts
CHANGED
|
@@ -276,6 +276,7 @@ type DocumentBookTarget = {
|
|
|
276
276
|
kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
|
|
277
277
|
caption?: string;
|
|
278
278
|
displayLabel?: string;
|
|
279
|
+
ordinal?: string;
|
|
279
280
|
manualKey?: string;
|
|
280
281
|
};
|
|
281
282
|
type DocumentBookContext = {
|
package/dist/book.js
CHANGED
|
@@ -5528,6 +5528,7 @@ function bookContextForUnit(snapshot, unitId) {
|
|
|
5528
5528
|
kind: t.kind,
|
|
5529
5529
|
...t.caption !== void 0 ? { caption: t.caption } : {},
|
|
5530
5530
|
...t.displayLabel !== void 0 ? { displayLabel: t.displayLabel } : {},
|
|
5531
|
+
...t.ordinal !== void 0 ? { ordinal: t.ordinal } : {},
|
|
5531
5532
|
...t.manualKey !== void 0 ? { manualKey: t.manualKey } : {}
|
|
5532
5533
|
})) };
|
|
5533
5534
|
}
|
|
@@ -5634,6 +5635,21 @@ function bookPreamble(snapshot) {
|
|
|
5634
5635
|
"\\renewcommand{\\contentsname}{\u0627\u0644\u0645\u062D\u062A\u0648\u064A\u0627\u062A}"
|
|
5635
5636
|
].join("\n");
|
|
5636
5637
|
}
|
|
5638
|
+
function normalizeBookEquationLabels(content, unitId, projection) {
|
|
5639
|
+
const aliases = /* @__PURE__ */ new Map();
|
|
5640
|
+
let latex = content;
|
|
5641
|
+
for (const target of projection.targets) {
|
|
5642
|
+
if (target.kind !== "eq" || !target.manualKey || target.manualKey === target.key) continue;
|
|
5643
|
+
aliases.set(target.manualKey, target.key);
|
|
5644
|
+
if (target.unitId === unitId) {
|
|
5645
|
+
const automatic = "\\label{" + target.key + "}";
|
|
5646
|
+
const manual = "\\label{" + target.manualKey + "}";
|
|
5647
|
+
latex = latex.replace(automatic + "\n" + manual, automatic);
|
|
5648
|
+
}
|
|
5649
|
+
}
|
|
5650
|
+
if (!aliases.size) return latex;
|
|
5651
|
+
return latex.replace(/\\(eqref|ref)\{([^}]*)\}/g, (_whole, command, keys) => "\\" + command + "{" + keys.split(",").map((key) => aliases.get(key.trim()) ?? key).join(",") + "}");
|
|
5652
|
+
}
|
|
5637
5653
|
function book2Latex(raw, _options = {}) {
|
|
5638
5654
|
const snapshot = normalizeBookSnapshot(raw);
|
|
5639
5655
|
const projection = resolveBookSnapshot(snapshot);
|
|
@@ -5701,7 +5717,7 @@ function book2Latex(raw, _options = {}) {
|
|
|
5701
5717
|
references: snapshot.references.references,
|
|
5702
5718
|
targets: projection.targets
|
|
5703
5719
|
};
|
|
5704
|
-
const content = documentContentLatex(fromDocumentJson(doc), context);
|
|
5720
|
+
const content = normalizeBookEquationLabels(documentContentLatex(fromDocumentJson(doc), context), entry.id, projection);
|
|
5705
5721
|
files[unitPath] = [unitBoundary(entry, projection, unnumbered), content, ""].join("\n\n");
|
|
5706
5722
|
main.push("\\input{" + unitPath + "}");
|
|
5707
5723
|
if (!((entry.type === "chapter" || entry.type === "appendix") && entry.numbered)) {
|