@baiyibai-antora/extensions 1.21.1 → 1.22.0

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/CHANGELOG.adoc CHANGED
@@ -3,6 +3,12 @@
3
3
 
4
4
  All notable changes to this project will be documented in this file.
5
5
 
6
+ == [1.22.0] - 2026-09-09
7
+
8
+ === Added
9
+
10
+ * xref-it: a new extension. A bare cross-component cross reference to a titled block or section, `+xref:component::page.adoc#id[]+` or `+<<component::page.adoc#id>>+`, rendered its raw resource spec as link text, because Antora's converter fills an empty reference that carries a fragment with the spec itself. At `contentClassified` the extension loads every page once through Antora's own `loadAsciiDoc`, with the page's component attributes and no Asciidoctor extensions, and collects its registered references by id: the `reftext` attribute when set, otherwise the raw block or section title, attribute references resolved in the page's own context. An Asciidoctor tree processor, registered in the site AsciiDoc config, then rewrites the empty text of a bare fragment reference whose target page belongs to another component while the page converts, for site HTML and the Confluence export alike, so the link text is the title alone, without a `Table N` or `Figure N` counter prefix. An Antora Assembler load is left untouched: the Assembler flattens the assembly into one document, where such a reference is a same-document xref and `xrefstyle` applies natively. The catalog source is never modified, a syntax example in a listing, literal, comment, or passthrough block is never seen, a reference inside an included partial resolves in the context of the including page, and a same-component, explicit-text, self, or fragment-free reference is left to Antora. A fragment the target does not define, or that names a block without a title or reftext, stays as written with a warning carrying the source location. The `signifier` option, off by default, prefixes the title with the signifier Asciidoctor itself uses for the block, read from the target page's own document attributes with the image block mapped to `figure-caption` explicitly, so a page's `:table-caption:` override is honored and an unset caption attribute yields the title alone; `signifier_separator` sets the text between the two; a `reftext` replaces the whole link text, signifier included. Eighteen tests drive a real content catalog and Antora's real loader and converter; the demonstration cross-references a table and a figure on a page of the extensions component from the docs component, and back
11
+
6
12
  == [1.21.1] - 2026-09-09
7
13
 
8
14
  === Fixed
package/README.adoc CHANGED
@@ -10,7 +10,7 @@ https://baiyibai-antora.gitlab.io
10
10
 
11
11
  == Overview
12
12
 
13
- This package provides eleven Antora extensions:
13
+ This package provides twelve Antora extensions:
14
14
 
15
15
  [cols="1,3"]
16
16
  |===
@@ -48,6 +48,9 @@ This package provides eleven Antora extensions:
48
48
 
49
49
  |<<user-content-list-of-site,list-of-site>>
50
50
  |Replaces `list-of::element[site]` placeholders with cross-page lists spanning the entire site
51
+
52
+ |<<user-content-xref-it,xref-it>>
53
+ |Renders a bare cross-component xref to a titled block or section with the target's own title or reftext as link text
51
54
  |===
52
55
 
53
56
  == Installation
@@ -200,6 +203,11 @@ include::docs/modules/ROOT/partials/trademark-it.adoc[tags=reference,leveloffset
200
203
 
201
204
  include::docs/modules/ROOT/partials/lists-extended-site.adoc[tags=reference,leveloffset=+2]
202
205
 
206
+ [[user-content-xref-it]]
207
+ === xref-it
208
+
209
+ include::docs/modules/ROOT/partials/xref-it.adoc[tags=reference,leveloffset=+2]
210
+
203
211
  == Vendorization
204
212
 
205
213
  To vendorize extensions into a project:
@@ -255,7 +263,8 @@ baiyibai-extensions/
255
263
  │ │ ├── asciidoctorconfig/
256
264
  │ │ ├── attribute-distiller/
257
265
  │ │ ├── trademark-it/
258
- │ │ └── list-of-site/
266
+ │ │ ├── list-of-site/
267
+ │ │ └── xref-it/
259
268
  │ └── lib/ # Shared helpers
260
269
  └── dist/ # Built output
261
270
  ----
@@ -0,0 +1,200 @@
1
+ /**
2
+ * @baiyibai-antora/extensions - xref-it
3
+ *
4
+ * Antora pipeline extension that renders a bare CROSS-COMPONENT xref to a
5
+ * block or section with the target's own reftext or title as link text, with
6
+ * no "Table N"/"Figure N" counter prefix.
7
+ *
8
+ * Antora's converter fills an empty `xref:component::page.adoc#id[]` with the
9
+ * raw resource spec (`compb::tables.adoc#fruit-table`) whenever a fragment is
10
+ * present, because the target page's block titles are unknown to it. This
11
+ * extension supplies them.
12
+ *
13
+ * Two halves:
14
+ * contentClassified - every page is loaded ONCE through Antora's own
15
+ * loadAsciiDoc (includes, conditionals, and component attributes
16
+ * resolve exactly as in the real conversion; registered Asciidoctor
17
+ * extensions are left out so nothing with side effects runs twice)
18
+ * and its registered references are collected by id: the `reftext`
19
+ * attribute when set, otherwise the raw block or section title,
20
+ * attribute references resolved in the target's own context.
21
+ * conversion - an Asciidoctor tree processor, registered in the site's
22
+ * AsciiDoc config, walks the parsed page and rewrites the empty
23
+ * text of a bare fragment xref whose target page belongs to
24
+ * ANOTHER component. It runs for ordinary page conversion (site
25
+ * HTML, and the Confluence export, which loads pages the same way)
26
+ * and steps aside for an Antora Assembler load: the Assembler
27
+ * flattens the assembly into one document, where such a reference
28
+ * becomes a same-document xref and xrefstyle applies natively.
29
+ *
30
+ * The catalog source is never modified. Working on the parsed tree means a
31
+ * syntax example in a listing, literal, comment, or passthrough block is never
32
+ * seen, and an xref inside an included partial is resolved in the context of
33
+ * the page that includes it.
34
+ *
35
+ * Registration in the playbook (list it AFTER extensions that generate the
36
+ * partials a page includes, such as autoterm or cite-it, so those partials
37
+ * exist when the pages are loaded for caption collection):
38
+ * antora:
39
+ * extensions:
40
+ * - require: '@baiyibai-antora/extensions/xref-it'
41
+ * xref_it:
42
+ * enabled: true
43
+ * quiet: true
44
+ * signifier: false
45
+ * signifier_separator: ': '
46
+ *
47
+ * With `signifier: true` the link text is prefixed by Asciidoctor's own
48
+ * signifier for the block, read from the target page's document attributes
49
+ * (`table-caption`, `figure-caption`, `listing-caption`, `example-caption`,
50
+ * `section-refsig`, `appendix-caption`), so a document that overrides its
51
+ * own word, `:table-caption: Tabelle`, is honored. No counter follows it:
52
+ * numbering is per document. A `reftext` replaces the whole text, signifier
53
+ * included, exactly as it does for Asciidoctor's own xrefstyle.
54
+ */
55
+ interface Src {
56
+ component: string;
57
+ version: string;
58
+ module: string;
59
+ family: string;
60
+ relative: string;
61
+ }
62
+ interface VirtualFile {
63
+ src: Src;
64
+ contents?: Buffer;
65
+ mediaType?: string;
66
+ path?: string;
67
+ }
68
+ interface AsciiDocConfig {
69
+ attributes?: Record<string, unknown>;
70
+ extensions?: unknown[];
71
+ [key: string]: unknown;
72
+ }
73
+ interface ComponentVersion {
74
+ asciidoc?: AsciiDocConfig;
75
+ }
76
+ interface ContentCatalog {
77
+ getFiles: (filter?: (file: VirtualFile) => boolean) => VirtualFile[];
78
+ getPages: (filter?: (file: VirtualFile) => boolean) => VirtualFile[];
79
+ resolveResource: (spec: string, context: Src, defaultFamily?: string, permittedFamilies?: string[]) => VirtualFile | false | undefined;
80
+ getComponentVersion: (component: string, version: string) => ComponentVersion | undefined;
81
+ }
82
+ /** The subset of an Asciidoctor.js node reachable from Document#getRefs(). */
83
+ interface RefNode {
84
+ getContext?: () => string;
85
+ getAttribute?: (name: string) => unknown;
86
+ getSectionName?: () => string | undefined;
87
+ /** Raw, unconverted `@title` instance variable; a Ruby nil arrives as an object. */
88
+ title?: unknown;
89
+ /** Raw reftext of an inline anchor node. */
90
+ text?: unknown;
91
+ }
92
+ interface SourceLocation {
93
+ getLineNumber?: () => number;
94
+ }
95
+ interface LogMessageOptions {
96
+ source_location?: SourceLocation | undefined;
97
+ }
98
+ interface DocLogger {
99
+ warn: (message: unknown) => void;
100
+ }
101
+ /** The subset of an Asciidoctor.js block tree node the tree processor walks. */
102
+ interface TreeNode {
103
+ getContext: () => string;
104
+ getBlocks?: () => TreeNode[];
105
+ getItems?: () => Array<TreeNode | TreeNode[]>;
106
+ getRows?: () => {
107
+ getHead: () => TreeNode[][];
108
+ getBody: () => TreeNode[][];
109
+ getFoot: () => TreeNode[][];
110
+ };
111
+ getStyle?: () => string | undefined;
112
+ getInnerDocument?: () => TreeNode | undefined;
113
+ getSubstitutions?: () => string[];
114
+ getSourceLocation?: () => SourceLocation | undefined;
115
+ /** Raw source lines of a simple or verse block. */
116
+ lines?: unknown;
117
+ /** Raw principal text of a list item or table cell. */
118
+ text?: unknown;
119
+ }
120
+ interface LoadedDocument extends TreeNode {
121
+ getRefs: () => Record<string, RefNode>;
122
+ getAttribute: (name: string) => unknown;
123
+ $sub_attributes?: (text: string) => string;
124
+ getLogger: () => DocLogger;
125
+ createLogMessage: (message: string, options: LogMessageOptions) => unknown;
126
+ }
127
+ interface ExtensionEntry {
128
+ require?: string;
129
+ [key: string]: unknown;
130
+ }
131
+ interface Playbook {
132
+ antora?: {
133
+ extensions?: ExtensionEntry[];
134
+ };
135
+ }
136
+ interface AntoraContext {
137
+ playbook: Playbook;
138
+ contentCatalog: ContentCatalog;
139
+ siteAsciiDocConfig?: AsciiDocConfig;
140
+ }
141
+ interface AntoraLogger {
142
+ debug?: (msg: string) => void;
143
+ info?: (msg: string) => void;
144
+ warn?: (msg: string) => void;
145
+ error?: (msg: string) => void;
146
+ }
147
+ interface Registry {
148
+ getLogger?: (name: string) => AntoraLogger;
149
+ getFunctions?: () => Record<string, unknown>;
150
+ replaceFunctions?: (updates: Record<string, unknown>) => void;
151
+ require?: (request: string) => unknown;
152
+ on: (event: string, callback: (context: AntoraContext) => void) => void;
153
+ once?: (event: string, callback: (context: AntoraContext) => void) => void;
154
+ }
155
+ export interface XrefItConfig {
156
+ enabled: boolean;
157
+ quiet: boolean;
158
+ signifier: boolean;
159
+ signifier_separator: string;
160
+ }
161
+ export interface Caption {
162
+ /** The reftext, or the raw title with attribute references resolved. */
163
+ text: string;
164
+ /** True when `text` is a reftext, which replaces the whole link text, signifier included. */
165
+ explicit: boolean;
166
+ /** The target document's own signifier for the block, when it defines one. */
167
+ signifier?: string;
168
+ }
169
+ export interface CaptionIndex {
170
+ /** id -> caption, for every reference that carries a reftext or title. */
171
+ captions: Map<string, Caption>;
172
+ /** Every registered id, captioned or not, so a missing id and a captionless one warn differently. */
173
+ ids: Set<string>;
174
+ }
175
+ export declare function readConfig(playbook: Playbook | undefined): XrefItConfig;
176
+ /**
177
+ * Escapes caption text for use as the sole positional attribute of an xref
178
+ * macro: a `]` is backslash-escaped, and text holding a comma or an equals
179
+ * sign is double-quoted so Asciidoctor's attribute list parser keeps it whole.
180
+ */
181
+ export declare function escapeXrefText(text: string): string;
182
+ /**
183
+ * The document attribute holding the signifier for a referenced node: the
184
+ * block's caption attribute, `section-refsig` for a section, and
185
+ * `appendix-caption` for an appendix section.
186
+ */
187
+ export declare function signifierAttributeName(node: RefNode): string | undefined;
188
+ /**
189
+ * Collects the id-to-caption map of a loaded document: the `reftext`
190
+ * attribute when set, otherwise the raw block or section title, otherwise
191
+ * an inline anchor's own reftext (an Inline node has no title; its context
192
+ * is `anchor` and its raw text is the reftext). Attribute references inside
193
+ * the caption resolve against the document that owns the caption.
194
+ */
195
+ export declare function collectCaptions(doc: LoadedDocument): CaptionIndex;
196
+ /** The link text for a caption under the given configuration. */
197
+ export declare function linkTextFor(caption: Caption, cfg: Pick<XrefItConfig, 'signifier' | 'signifier_separator'>): string;
198
+ export declare function register(context: Registry): void;
199
+ export {};
200
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/xref-it/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAMH,UAAU,GAAG;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,WAAW;IACnB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,UAAU,cAAc;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,UAAU,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AC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,qGAAqG;IACrG,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAClB;AAWD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,YAAY,CAWvE;AAQD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAInD;AAkBD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKxE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,YAAY,CAmBjE;AAED,iEAAiE;AACjE,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,WAAW,GAAG,qBAAqB,CAAC,GAAG,MAAM,CAGlH;AA2CD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAsLhD"}
@@ -0,0 +1,395 @@
1
+ "use strict";
2
+ /**
3
+ * @baiyibai-antora/extensions - xref-it
4
+ *
5
+ * Antora pipeline extension that renders a bare CROSS-COMPONENT xref to a
6
+ * block or section with the target's own reftext or title as link text, with
7
+ * no "Table N"/"Figure N" counter prefix.
8
+ *
9
+ * Antora's converter fills an empty `xref:component::page.adoc#id[]` with the
10
+ * raw resource spec (`compb::tables.adoc#fruit-table`) whenever a fragment is
11
+ * present, because the target page's block titles are unknown to it. This
12
+ * extension supplies them.
13
+ *
14
+ * Two halves:
15
+ * contentClassified - every page is loaded ONCE through Antora's own
16
+ * loadAsciiDoc (includes, conditionals, and component attributes
17
+ * resolve exactly as in the real conversion; registered Asciidoctor
18
+ * extensions are left out so nothing with side effects runs twice)
19
+ * and its registered references are collected by id: the `reftext`
20
+ * attribute when set, otherwise the raw block or section title,
21
+ * attribute references resolved in the target's own context.
22
+ * conversion - an Asciidoctor tree processor, registered in the site's
23
+ * AsciiDoc config, walks the parsed page and rewrites the empty
24
+ * text of a bare fragment xref whose target page belongs to
25
+ * ANOTHER component. It runs for ordinary page conversion (site
26
+ * HTML, and the Confluence export, which loads pages the same way)
27
+ * and steps aside for an Antora Assembler load: the Assembler
28
+ * flattens the assembly into one document, where such a reference
29
+ * becomes a same-document xref and xrefstyle applies natively.
30
+ *
31
+ * The catalog source is never modified. Working on the parsed tree means a
32
+ * syntax example in a listing, literal, comment, or passthrough block is never
33
+ * seen, and an xref inside an included partial is resolved in the context of
34
+ * the page that includes it.
35
+ *
36
+ * Registration in the playbook (list it AFTER extensions that generate the
37
+ * partials a page includes, such as autoterm or cite-it, so those partials
38
+ * exist when the pages are loaded for caption collection):
39
+ * antora:
40
+ * extensions:
41
+ * - require: '@baiyibai-antora/extensions/xref-it'
42
+ * xref_it:
43
+ * enabled: true
44
+ * quiet: true
45
+ * signifier: false
46
+ * signifier_separator: ': '
47
+ *
48
+ * With `signifier: true` the link text is prefixed by Asciidoctor's own
49
+ * signifier for the block, read from the target page's document attributes
50
+ * (`table-caption`, `figure-caption`, `listing-caption`, `example-caption`,
51
+ * `section-refsig`, `appendix-caption`), so a document that overrides its
52
+ * own word, `:table-caption: Tabelle`, is honored. No counter follows it:
53
+ * numbering is per document. A `reftext` replaces the whole text, signifier
54
+ * included, exactly as it does for Asciidoctor's own xrefstyle.
55
+ */
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.readConfig = readConfig;
58
+ exports.escapeXrefText = escapeXrefText;
59
+ exports.signifierAttributeName = signifierAttributeName;
60
+ exports.collectCaptions = collectCaptions;
61
+ exports.linkTextFor = linkTextFor;
62
+ exports.register = register;
63
+ const log_time_1 = require("../../lib/log-time");
64
+ // ── Configuration ─────────────────────────────────────────────────────────────
65
+ function pick(raw, keys, fallback) {
66
+ for (const key of keys) {
67
+ if (key in raw && raw[key] !== undefined)
68
+ return raw[key];
69
+ }
70
+ return fallback;
71
+ }
72
+ function readConfig(playbook) {
73
+ const entries = playbook?.antora?.extensions ?? [];
74
+ const me = entries.find((entry) => String(entry?.require ?? '').includes('xref-it')) ?? {};
75
+ const candidate = me.xrefIt ?? me.xref_it ?? me.xrefit;
76
+ const raw = (candidate && typeof candidate === 'object' ? candidate : {});
77
+ return {
78
+ enabled: pick(raw, ['enabled'], true),
79
+ quiet: pick(raw, ['quiet'], true),
80
+ signifier: pick(raw, ['signifier'], false),
81
+ signifier_separator: String(pick(raw, ['signifier_separator', 'signifierSeparator'], ': ')),
82
+ };
83
+ }
84
+ // ── Xref detection and text escaping ──────────────────────────────────────────
85
+ // A bare fragment xref: a page spec ending in .adoc, a fragment, and empty text.
86
+ const XREF_MACRO_RE = /(?<![\\+])xref:([^\s[\]#]*\.adoc)#([^\s[\]#]+)\[\]/g;
87
+ const XREF_SHORTHAND_RE = /(?<![\\+])<<([^\s<>,#]*\.adoc)#([^\s<>,#]+)>>/g;
88
+ /**
89
+ * Escapes caption text for use as the sole positional attribute of an xref
90
+ * macro: a `]` is backslash-escaped, and text holding a comma or an equals
91
+ * sign is double-quoted so Asciidoctor's attribute list parser keeps it whole.
92
+ */
93
+ function escapeXrefText(text) {
94
+ let escaped = text.replace(/\]/g, '\\]');
95
+ if (/[,=]/.test(escaped))
96
+ escaped = `"${escaped.replace(/"/g, '\\"')}"`;
97
+ return escaped;
98
+ }
99
+ // ── Caption collection ────────────────────────────────────────────────────────
100
+ function rawString(value) {
101
+ return typeof value === 'string' && value.trim() !== '' ? value : undefined;
102
+ }
103
+ // Asciidoctor's own CAPTION_ATTRIBUTE_NAMES is keyed by the caption kind, where
104
+ // a real image block is 'figure' while its context is 'image', so the image
105
+ // case is mapped explicitly rather than looked up by context.
106
+ const CAPTION_ATTRIBUTE_NAMES = {
107
+ example: 'example-caption',
108
+ figure: 'figure-caption',
109
+ listing: 'listing-caption',
110
+ table: 'table-caption',
111
+ };
112
+ /**
113
+ * The document attribute holding the signifier for a referenced node: the
114
+ * block's caption attribute, `section-refsig` for a section, and
115
+ * `appendix-caption` for an appendix section.
116
+ */
117
+ function signifierAttributeName(node) {
118
+ const context = node.getContext?.();
119
+ if (context === 'image')
120
+ return 'figure-caption';
121
+ if (context === 'section')
122
+ return node.getSectionName?.() === 'appendix' ? 'appendix-caption' : 'section-refsig';
123
+ return context ? CAPTION_ATTRIBUTE_NAMES[context] : undefined;
124
+ }
125
+ /**
126
+ * Collects the id-to-caption map of a loaded document: the `reftext`
127
+ * attribute when set, otherwise the raw block or section title, otherwise
128
+ * an inline anchor's own reftext (an Inline node has no title; its context
129
+ * is `anchor` and its raw text is the reftext). Attribute references inside
130
+ * the caption resolve against the document that owns the caption.
131
+ */
132
+ function collectCaptions(doc) {
133
+ const captions = new Map();
134
+ const ids = new Set();
135
+ const refs = doc.getRefs() ?? {};
136
+ for (const [id, node] of Object.entries(refs)) {
137
+ if (!node || typeof node !== 'object')
138
+ continue;
139
+ ids.add(id);
140
+ const reftext = rawString(node.getAttribute?.('reftext'));
141
+ let text = reftext ?? rawString(node.title);
142
+ if (text === undefined && node.getContext?.() === 'anchor')
143
+ text = rawString(node.text);
144
+ if (text === undefined)
145
+ continue;
146
+ if (text.includes('{') && typeof doc.$sub_attributes === 'function')
147
+ text = doc.$sub_attributes(text);
148
+ const caption = { text: text.trim(), explicit: reftext !== undefined };
149
+ const attributeName = signifierAttributeName(node);
150
+ const signifier = attributeName ? rawString(doc.getAttribute(attributeName)) : undefined;
151
+ if (signifier)
152
+ caption.signifier = signifier.trim();
153
+ captions.set(id, caption);
154
+ }
155
+ return { captions, ids };
156
+ }
157
+ /** The link text for a caption under the given configuration. */
158
+ function linkTextFor(caption, cfg) {
159
+ if (!cfg.signifier || caption.explicit || !caption.signifier)
160
+ return caption.text;
161
+ return `${caption.signifier}${cfg.signifier_separator}${caption.text}`;
162
+ }
163
+ // ── Helpers ───────────────────────────────────────────────────────────────────
164
+ function resolveLoader(context) {
165
+ const fromContextRequire = (() => {
166
+ try {
167
+ return context.require?.('@antora/asciidoc-loader')?.loadAsciiDoc;
168
+ }
169
+ catch {
170
+ return undefined;
171
+ }
172
+ })();
173
+ const fromFunctions = context.getFunctions?.().loadAsciiDoc;
174
+ const fromRequire = (() => {
175
+ try {
176
+ return require('@antora/asciidoc-loader').loadAsciiDoc;
177
+ }
178
+ catch {
179
+ return undefined;
180
+ }
181
+ })();
182
+ const loader = fromContextRequire ?? fromFunctions ?? fromRequire;
183
+ return typeof loader === 'function' ? loader : undefined;
184
+ }
185
+ function describe(file) {
186
+ const { component, version, module, family, relative } = file.src;
187
+ const versionPart = version ? `${version}@` : '';
188
+ return `${versionPart}${component}:${module}:${family}$${relative}`;
189
+ }
190
+ function isAsciiDocPage(file) {
191
+ if (file.src?.family !== 'page' || !file.contents)
192
+ return false;
193
+ return file.mediaType === 'text/asciidoc' || /\.adoc$/.test(file.src.relative);
194
+ }
195
+ /** True for a load the Antora Assembler performs while flattening an assembly. */
196
+ function isAssemblerLoad(config) {
197
+ const attributes = config?.attributes;
198
+ return !!attributes && 'loader-assembler' in attributes && attributes['loader-assembler'] !== false;
199
+ }
200
+ // ── Extension ─────────────────────────────────────────────────────────────────
201
+ function register(context) {
202
+ const antoraLogger = context.getLogger?.('xref-it');
203
+ const warn = (message) => {
204
+ if (antoraLogger?.warn)
205
+ antoraLogger.warn(message);
206
+ else
207
+ console.warn(`[${(0, log_time_1.nowLocal)()}] WARN (xref-it): ${message}`);
208
+ };
209
+ const info = (message) => {
210
+ console.log(`[${(0, log_time_1.nowLocal)()}] \x1b[94mEVENT\x1b[0m (xref-it): \x1b[94m${message}\x1b[0m`);
211
+ };
212
+ let enabled = true;
213
+ let cfg = readConfig(undefined);
214
+ let loadAsciiDoc;
215
+ let catalogRef;
216
+ let siteConfigRef;
217
+ const captionCache = new Map();
218
+ const indexFor = (target) => {
219
+ if (captionCache.has(target))
220
+ return captionCache.get(target);
221
+ let index = null;
222
+ if (loadAsciiDoc && catalogRef) {
223
+ try {
224
+ const scoped = catalogRef.getComponentVersion(target.src.component, target.src.version)?.asciidoc;
225
+ const baseConfig = scoped ?? siteConfigRef ?? {};
226
+ // Registered Asciidoctor extensions, this one included, are left out:
227
+ // this load exists to read titles, and a block processor with side
228
+ // effects, such as a diagram fetch, would otherwise run twice.
229
+ const config = Object.assign({}, baseConfig, { extensions: [] });
230
+ index = collectCaptions(loadAsciiDoc(target, catalogRef, config));
231
+ }
232
+ catch (err) {
233
+ warn(`${describe(target)}: load failed while collecting captions (${err.message})`);
234
+ }
235
+ }
236
+ captionCache.set(target, index);
237
+ return index;
238
+ };
239
+ // ── The conversion-time half: an Asciidoctor tree processor ────────────────
240
+ const asciidoctorExtension = {
241
+ register(registry, { file, contentCatalog, config }) {
242
+ if (!enabled || !file || file.src?.family !== 'page' || isAssemblerLoad(config))
243
+ return;
244
+ registry.treeProcessor(function () {
245
+ this.process((doc) => rewriteDocument(doc, file, contentCatalog));
246
+ });
247
+ },
248
+ };
249
+ function rewriteDocument(doc, file, contentCatalog) {
250
+ const logMissing = (node, message) => {
251
+ try {
252
+ doc.getLogger().warn(doc.createLogMessage(message, { source_location: node.getSourceLocation?.() }));
253
+ }
254
+ catch {
255
+ warn(`${describe(file)}: ${message}`);
256
+ }
257
+ };
258
+ const rewriteText = (node, text) => {
259
+ const replace = (match, spec, fragment) => {
260
+ const target = contentCatalog.resolveResource(spec, file.src, 'page', ['page']);
261
+ if (!target || target === file || target.src.component === file.src.component)
262
+ return match;
263
+ const index = indexFor(target);
264
+ if (!index)
265
+ return match;
266
+ const caption = index.captions.get(fragment);
267
+ if (caption === undefined) {
268
+ const reason = index.ids.has(fragment) ? 'carries no title or reftext' : 'is not defined';
269
+ logMissing(node, `xref-it: fragment #${fragment} ${reason} in ${spec}; xref left as written`);
270
+ return match;
271
+ }
272
+ return `xref:${spec}#${fragment}[${escapeXrefText(linkTextFor(caption, cfg))}]`;
273
+ };
274
+ return text.replace(XREF_MACRO_RE, replace).replace(XREF_SHORTHAND_RE, replace);
275
+ };
276
+ const rewriteLines = (node) => {
277
+ const lines = node.lines;
278
+ if (!Array.isArray(lines))
279
+ return;
280
+ for (let idx = 0; idx < lines.length; idx++) {
281
+ const line = lines[idx];
282
+ if (typeof line === 'string' && line.includes('.adoc#'))
283
+ lines[idx] = rewriteText(node, line);
284
+ }
285
+ };
286
+ const rewritePrincipalText = (node) => {
287
+ if (typeof node.text === 'string' && node.text.includes('.adoc#'))
288
+ node.text = rewriteText(node, node.text);
289
+ };
290
+ const walk = (node) => {
291
+ if (!node || typeof node.getContext !== 'function')
292
+ return;
293
+ const ctx = node.getContext();
294
+ if (ctx === 'table') {
295
+ const rows = node.getRows?.();
296
+ if (rows) {
297
+ for (const row of [...rows.getHead(), ...rows.getBody(), ...rows.getFoot()]) {
298
+ for (const cell of row) {
299
+ const inner = cell.getStyle?.() === 'asciidoc' ? cell.getInnerDocument?.() : undefined;
300
+ if (inner)
301
+ walk(inner);
302
+ else
303
+ rewritePrincipalText(cell);
304
+ }
305
+ }
306
+ }
307
+ return;
308
+ }
309
+ if (ctx === 'dlist') {
310
+ for (const item of node.getItems?.() ?? []) {
311
+ if (Array.isArray(item)) {
312
+ const [terms, description] = item;
313
+ for (const term of Array.isArray(terms) ? terms : [terms])
314
+ rewritePrincipalText(term);
315
+ if (description)
316
+ walk(description);
317
+ }
318
+ }
319
+ return;
320
+ }
321
+ if (ctx === 'list_item') {
322
+ rewritePrincipalText(node);
323
+ }
324
+ else if (Array.isArray(node.lines)) {
325
+ // A simple or verse block carries its raw source lines; only rewrite
326
+ // where the macros substitution is active, so a listing or literal
327
+ // block that shows the syntax is left alone.
328
+ const subs = node.getSubstitutions?.();
329
+ if (Array.isArray(subs) && subs.includes('macros'))
330
+ rewriteLines(node);
331
+ }
332
+ for (const child of node.getBlocks?.() ?? [])
333
+ walk(child);
334
+ };
335
+ walk(doc);
336
+ }
337
+ const install = (config) => {
338
+ if (!config)
339
+ return;
340
+ if (!Array.isArray(config.extensions))
341
+ config.extensions = [];
342
+ if (!config.extensions.includes(asciidoctorExtension))
343
+ config.extensions.push(asciidoctorExtension);
344
+ };
345
+ // Register the tree processor in the site AsciiDoc config the moment Antora
346
+ // resolves it, before any component-version config is derived from it.
347
+ context.once?.('contextStarted', () => {
348
+ const delegate = context.getFunctions?.().resolveAsciiDocConfig;
349
+ if (typeof delegate !== 'function' || !context.replaceFunctions)
350
+ return;
351
+ context.replaceFunctions({
352
+ resolveAsciiDocConfig: (playbook) => {
353
+ const config = delegate(playbook);
354
+ install(config);
355
+ return config;
356
+ },
357
+ });
358
+ });
359
+ // ── The classification-time half: collect every page's captions ───────────
360
+ context.on('contentClassified', ({ playbook, contentCatalog, siteAsciiDocConfig }) => {
361
+ cfg = readConfig(playbook);
362
+ enabled = cfg.enabled;
363
+ if (!enabled)
364
+ return;
365
+ if (!contentCatalog) {
366
+ warn('contentCatalog not available; no xref rewritten');
367
+ enabled = false;
368
+ return;
369
+ }
370
+ // Component-version configs share the site config's extensions array by
371
+ // reference, so this late install still reaches them when contextStarted
372
+ // was unavailable.
373
+ install(siteAsciiDocConfig);
374
+ loadAsciiDoc = resolveLoader(context);
375
+ if (!loadAsciiDoc) {
376
+ warn('@antora/asciidoc-loader not resolvable; no xref rewritten');
377
+ enabled = false;
378
+ return;
379
+ }
380
+ catalogRef = contentCatalog;
381
+ siteConfigRef = siteAsciiDocConfig;
382
+ let pageCount = 0;
383
+ let captionCount = 0;
384
+ for (const page of contentCatalog.getPages(isAsciiDocPage)) {
385
+ const index = indexFor(page);
386
+ if (!index)
387
+ continue;
388
+ pageCount++;
389
+ captionCount += index.captions.size;
390
+ }
391
+ if (!cfg.quiet)
392
+ info(`Collected ${captionCount} caption(s) from ${pageCount} page(s)`);
393
+ });
394
+ }
395
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/xref-it/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;;A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B;QACnB,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAC5B,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,IAAI,CAAC,2DAA2D,CAAC,CAAC;YAClE,OAAO,GAAG,KAAK,CAAC;YAChB,OAAO;QACT,CAAC;QACD,UAAU,GAAG,cAAc,CAAC;QAC5B,aAAa,GAAG,kBAAkB,CAAC;QAEnC,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,KAAK,MAAM,IAAI,IAAI,cAAc,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;YAC3D,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,CAAC,KAAK;gBAAE,SAAS;YACrB,SAAS,EAAE,CAAC;YACZ,YAAY,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,KAAK;YAAE,IAAI,CAAC,aAAa,YAAY,oBAAoB,SAAS,UAAU,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baiyibai-antora/extensions",
3
- "version": "1.21.1",
3
+ "version": "1.22.0",
4
4
  "description": "Antora extensions and AsciiDoc macros for Baiyibai documentation",
5
5
  "keywords": [
6
6
  "antora",
@@ -51,6 +51,10 @@
51
51
  "require": "./dist/extensions/list-of-site/index.js",
52
52
  "types": "./dist/extensions/list-of-site/index.d.ts"
53
53
  },
54
+ "./xref-it": {
55
+ "require": "./dist/extensions/xref-it/index.js",
56
+ "types": "./dist/extensions/xref-it/index.d.ts"
57
+ },
54
58
  "./trademark-it": {
55
59
  "require": "./dist/extensions/trademark-it/index.js",
56
60
  "types": "./dist/extensions/trademark-it/index.d.ts"