@drghaliasri/butex 8.1.2 → 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.
@@ -320,6 +320,7 @@ type DocumentBookTarget = {
320
320
  kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
321
321
  caption?: string;
322
322
  displayLabel?: string;
323
+ ordinal?: string;
323
324
  manualKey?: string;
324
325
  };
325
326
  type DocumentBookContext = {
@@ -320,6 +320,7 @@ type DocumentBookTarget = {
320
320
  kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
321
321
  caption?: string;
322
322
  displayLabel?: string;
323
+ ordinal?: string;
323
324
  manualKey?: string;
324
325
  };
325
326
  type DocumentBookContext = {
@@ -4618,6 +4618,11 @@ function mathTokenSourceForSide(token, side, digitForm, presentation = false) {
4618
4618
  function mathTex(token, equationSide, digitForm) {
4619
4619
  return mathTokenSourceForSide(token, equationSide, digitForm, true);
4620
4620
  }
4621
+ function projectedBookTarget(options, ownerId, kind) {
4622
+ if (options.mode !== "book-content") return void 0;
4623
+ const book = options.bookContext;
4624
+ return book?.targets?.find((target) => target.unitId === book.unitId && target.ownerId === ownerId && target.kind === kind);
4625
+ }
4621
4626
  function previewInlines(field, islands, output, equationSide, document2, previewOptions) {
4622
4627
  return field.tokens.map((token) => {
4623
4628
  if (token.kind === "text") {
@@ -4649,7 +4654,8 @@ function previewInlines(field, islands, output, equationSide, document2, preview
4649
4654
  })
4650
4655
  };
4651
4656
  }
4652
- const number = collectDocumentReferenceTargets(document2).find((target) => target.kind === "eq" && target.ownerId === token.id)?.number;
4657
+ const projected = projectedBookTarget(previewOptions, token.id, "eq");
4658
+ const number = projected ? void 0 : collectDocumentReferenceTargets(document2).find((target) => target.kind === "eq" && target.ownerId === token.id)?.number;
4653
4659
  const island = {
4654
4660
  id: token.id,
4655
4661
  tex: mathTex(token, equationSide, previewOptions.digitForm),
@@ -4657,7 +4663,7 @@ function previewInlines(field, islands, output, equationSide, document2, preview
4657
4663
  output,
4658
4664
  editable: token.editable
4659
4665
  };
4660
- const numberLabel = number == null ? void 0 : formatBibliographyNumber(number, {
4666
+ const numberLabel = projected ? projected.ordinal : number == null ? void 0 : formatBibliographyNumber(number, {
4661
4667
  documentDirection: previewOptions.documentDirection,
4662
4668
  digitForm: previewOptions.digitForm
4663
4669
  });
@@ -4686,6 +4692,8 @@ function textBlockPreview(block, islands, output, equationSide, document2, previ
4686
4692
  };
4687
4693
  }
4688
4694
  function floatNumberLabel(document2, ownerId, previewOptions) {
4695
+ const projected = projectedBookTarget(previewOptions, ownerId, "fig") ?? projectedBookTarget(previewOptions, ownerId, "tab");
4696
+ if (projected) return projected.displayLabel;
4689
4697
  const hit = collectDocumentReferenceTargets(document2).find((target) => target.ownerId === ownerId);
4690
4698
  if (!hit || hit.number === null || hit.kind !== "fig" && hit.kind !== "tab") {
4691
4699
  return void 0;