@baiyibai-antora/extensions 1.13.0 → 1.14.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 +18 -0
- package/README.adoc +17 -1
- package/dist/extensions/attribute-distiller/index.d.ts +6 -0
- package/dist/extensions/attribute-distiller/index.d.ts.map +1 -1
- package/dist/extensions/attribute-distiller/index.js +92 -16
- package/dist/extensions/attribute-distiller/index.js.map +1 -1
- package/dist/extensions/autoterm/index.d.ts +29 -18
- package/dist/extensions/autoterm/index.d.ts.map +1 -1
- package/dist/extensions/autoterm/index.js +37 -197
- package/dist/extensions/autoterm/index.js.map +1 -1
- package/dist/extensions/cite-it/asciidoc.d.ts +29 -0
- package/dist/extensions/cite-it/asciidoc.d.ts.map +1 -0
- package/dist/extensions/cite-it/asciidoc.js +32 -0
- package/dist/extensions/cite-it/asciidoc.js.map +1 -0
- package/dist/extensions/cite-it/assembly-numbering.d.ts +202 -0
- package/dist/extensions/cite-it/assembly-numbering.d.ts.map +1 -0
- package/dist/extensions/cite-it/assembly-numbering.js +385 -0
- package/dist/extensions/cite-it/assembly-numbering.js.map +1 -0
- package/dist/extensions/cite-it/csl.d.ts +45 -0
- package/dist/extensions/cite-it/csl.d.ts.map +1 -0
- package/dist/extensions/cite-it/csl.js +139 -0
- package/dist/extensions/cite-it/csl.js.map +1 -0
- package/dist/extensions/cite-it/index.d.ts +300 -0
- package/dist/extensions/cite-it/index.d.ts.map +1 -0
- package/dist/extensions/cite-it/index.js +1098 -0
- package/dist/extensions/cite-it/index.js.map +1 -0
- package/dist/extensions/cite-it/macro.d.ts +104 -0
- package/dist/extensions/cite-it/macro.d.ts.map +1 -0
- package/dist/extensions/cite-it/macro.js +245 -0
- package/dist/extensions/cite-it/macro.js.map +1 -0
- package/dist/extensions/cite-it/registry.d.ts +64 -0
- package/dist/extensions/cite-it/registry.d.ts.map +1 -0
- package/dist/extensions/cite-it/registry.js +157 -0
- package/dist/extensions/cite-it/registry.js.map +1 -0
- package/dist/extensions/trademark-it/index.d.ts +91 -22
- package/dist/extensions/trademark-it/index.d.ts.map +1 -1
- package/dist/extensions/trademark-it/index.js +239 -242
- package/dist/extensions/trademark-it/index.js.map +1 -1
- package/dist/lib/asciidoc-conditionals.d.ts +59 -0
- package/dist/lib/asciidoc-conditionals.d.ts.map +1 -0
- package/dist/lib/asciidoc-conditionals.js +0 -0
- package/dist/lib/asciidoc-conditionals.js.map +1 -0
- package/dist/lib/asciidoc-indexterms.d.ts +126 -0
- package/dist/lib/asciidoc-indexterms.d.ts.map +1 -0
- package/dist/lib/asciidoc-indexterms.js +261 -0
- package/dist/lib/asciidoc-indexterms.js.map +1 -0
- package/dist/lib/asciidoc-table.d.ts +32 -0
- package/dist/lib/asciidoc-table.d.ts.map +1 -0
- package/dist/lib/asciidoc-table.js +55 -0
- package/dist/lib/asciidoc-table.js.map +1 -0
- package/package.json +19 -4
- package/resources/cite-it/ieee-bracket.csl +519 -0
- package/resources/cite-it/locale-en-US.xml +864 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* cite-it: `.bib` parsing and CSL-JSON registry merging.
|
|
4
|
+
*
|
|
5
|
+
* Parses BibTeX/BibLaTeX source text into CSL-JSON items keyed by the
|
|
6
|
+
* entry's real citation key, using `biblatex-csl-converter` rather than a
|
|
7
|
+
* hand-rolled `.bib` grammar parser (the same "favor the API over regex"
|
|
8
|
+
* reasoning this codebase already applies elsewhere; see the root
|
|
9
|
+
* `CLAUDE.md`, "Content Extraction: Favor the API Over Regex").
|
|
10
|
+
*
|
|
11
|
+
* `biblatex-csl-converter`'s own CSL export, verified directly against a
|
|
12
|
+
* real `.bib` sample rather than assumed from its documentation, carries
|
|
13
|
+
* two correctness gaps relevant to the entry types this extension's bundled
|
|
14
|
+
* `ieee-bracket` style actually branches on:
|
|
15
|
+
*
|
|
16
|
+
* - The exported item's `id` is the parser's own numeric result key
|
|
17
|
+
* ("1", "2", ...), never the real BibTeX citation key. `citeit:[key]`
|
|
18
|
+
* needs the real key to look an entry up at all, so it is restored from
|
|
19
|
+
* `entry_key` after export.
|
|
20
|
+
* - A plain BibTeX `@article` entry with a `journaltitle`/`journal` field
|
|
21
|
+
* exports as CSL type `article`, not `article-journal`. The two are
|
|
22
|
+
* both valid CSL types, but the `ieee-bracket` style's bibliography
|
|
23
|
+
* layout branches on `article-journal` for the volume/issue/page
|
|
24
|
+
* citation form real journal articles need; plain `article` falls
|
|
25
|
+
* through to a differently-shaped fallback branch instead. Remapped
|
|
26
|
+
* here when a `container-title` is present, the signal that the entry
|
|
27
|
+
* is really a journal article.
|
|
28
|
+
* - The BibTeX `number` field on an `@article` entry means the issue
|
|
29
|
+
* number, but the exporter maps it to CSL `collection-number` (correct
|
|
30
|
+
* for `@book`/`@report`-shaped series numbers, wrong for a journal
|
|
31
|
+
* article's issue). Remapped to `issue` specifically for the
|
|
32
|
+
* `article-journal` case, not applied to any other entry type.
|
|
33
|
+
* - A custom `supersededby` field, naming the citation key of a newer
|
|
34
|
+
* entry replacing this one, is not a real BibLaTeX field and never
|
|
35
|
+
* reaches CSL export at all (verified directly): read from the raw
|
|
36
|
+
* parsed entry instead and reattached to the exported CSL item under
|
|
37
|
+
* the same name. index.ts warns, once per category's generated
|
|
38
|
+
* partial, when an actually-cited or `ref_force`d entry carries it.
|
|
39
|
+
*/
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.parseCiteFile = parseCiteFile;
|
|
42
|
+
exports.mergeCiteRegistry = mergeCiteRegistry;
|
|
43
|
+
// biblatex-csl-converter ships as a dual CJS/ESM package with a single
|
|
44
|
+
// `types` entry written as ESM; TypeScript's node16 resolution flags both a
|
|
45
|
+
// static `import` and a typed `typeof import(...)` of it as a CJS-requiring-
|
|
46
|
+
// ESM error, even though the package's own "require" export condition
|
|
47
|
+
// resolves correctly at runtime. Required untyped and re-typed against the
|
|
48
|
+
// minimal local shapes below, which sidesteps that resolution-mode check
|
|
49
|
+
// entirely rather than fighting it.
|
|
50
|
+
const bibtexModule = require('biblatex-csl-converter');
|
|
51
|
+
/** Flattens one custom field's rich-text run array down to plain text.
|
|
52
|
+
* Returns `undefined` for a missing field or one that flattens to nothing,
|
|
53
|
+
* so a caller can `??`/truthiness-check without a separate emptiness check.
|
|
54
|
+
*/
|
|
55
|
+
function plainTextField(value) {
|
|
56
|
+
if (!Array.isArray(value))
|
|
57
|
+
return undefined;
|
|
58
|
+
const text = value
|
|
59
|
+
.map((node) => (node && typeof node === 'object' && typeof node.text === 'string'
|
|
60
|
+
? node.text
|
|
61
|
+
: ''))
|
|
62
|
+
.join('')
|
|
63
|
+
.trim();
|
|
64
|
+
return text || undefined;
|
|
65
|
+
}
|
|
66
|
+
const parse = bibtexModule.parse;
|
|
67
|
+
const CSLExporter = bibtexModule.CSLExporter;
|
|
68
|
+
/**
|
|
69
|
+
* Parse one `.bib` file's raw text into a Map of citation key to CSL-JSON
|
|
70
|
+
* item. `sourceLabel` identifies the file in warning messages only (for
|
|
71
|
+
* example a catalog path); parse warnings from a malformed entry are
|
|
72
|
+
* returned rather than thrown, so one bad entry in a large shared file does
|
|
73
|
+
* not fail the whole build.
|
|
74
|
+
*/
|
|
75
|
+
function parseCiteFile(bibText, sourceLabel) {
|
|
76
|
+
const entries = new Map();
|
|
77
|
+
const warnings = [];
|
|
78
|
+
let parsed;
|
|
79
|
+
try {
|
|
80
|
+
parsed = parse(bibText, { processUnexpected: true, processUnknown: true });
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
warnings.push(`${sourceLabel}: could not parse .bib source: ${String(err)}`);
|
|
84
|
+
return { entries, warnings };
|
|
85
|
+
}
|
|
86
|
+
for (const w of parsed.warnings ?? []) {
|
|
87
|
+
// biblatex-csl-converter warns about every field name it does not
|
|
88
|
+
// recognize, useful for catching a genuine typo in a field name, but
|
|
89
|
+
// supersededby (see plainTextField above) is a recognized cite-it
|
|
90
|
+
// convention, not a mistake; forwarding this specific warning would
|
|
91
|
+
// fire on every correctly-used supersededby entry, alongside index.ts's
|
|
92
|
+
// own, more useful warning naming the actual newer key. Any other
|
|
93
|
+
// unrecognized field still warns normally.
|
|
94
|
+
const warning = w;
|
|
95
|
+
if (warning?.type === 'unknown_field' && warning.field_name === 'supersededby')
|
|
96
|
+
continue;
|
|
97
|
+
warnings.push(`${sourceLabel}: ${JSON.stringify(w)}`);
|
|
98
|
+
}
|
|
99
|
+
const numericKeys = Object.keys(parsed.entries).map(Number);
|
|
100
|
+
if (numericKeys.length === 0)
|
|
101
|
+
return { entries, warnings };
|
|
102
|
+
const exporter = new CSLExporter(parsed.entries);
|
|
103
|
+
const csl = exporter.parse();
|
|
104
|
+
for (const numericKey of numericKeys) {
|
|
105
|
+
const rawEntry = parsed.entries[numericKey];
|
|
106
|
+
const cslItem = csl[String(numericKey)];
|
|
107
|
+
if (!cslItem)
|
|
108
|
+
continue;
|
|
109
|
+
const citationKey = rawEntry.entry_key;
|
|
110
|
+
if (!citationKey) {
|
|
111
|
+
warnings.push(`${sourceLabel}: entry ${numericKey} has no citation key; skipped`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
cslItem.id = citationKey;
|
|
115
|
+
// supersededby names another citation key: not a real BibLaTeX field,
|
|
116
|
+
// so it never reaches CSL export (see plainTextField's own docblock)
|
|
117
|
+
// and is read from the raw parsed entry instead, then reattached to
|
|
118
|
+
// the exported CSL item under the same name so index.ts's later
|
|
119
|
+
// superseded-entry check can read it the same way it reads any other
|
|
120
|
+
// CSL field.
|
|
121
|
+
const supersededBy = plainTextField(rawEntry.unknown_fields?.['supersededby'])
|
|
122
|
+
?? plainTextField(rawEntry.fields?.['supersededby']);
|
|
123
|
+
if (supersededBy)
|
|
124
|
+
cslItem['supersededby'] = supersededBy;
|
|
125
|
+
// See the module docblock: article vs. article-journal, and the
|
|
126
|
+
// article-only number -> issue remap.
|
|
127
|
+
if (cslItem.type === 'article' && typeof cslItem['container-title'] === 'string' && cslItem['container-title']) {
|
|
128
|
+
cslItem.type = 'article-journal';
|
|
129
|
+
if (cslItem['collection-number'] !== undefined && cslItem['issue'] === undefined) {
|
|
130
|
+
cslItem['issue'] = cslItem['collection-number'];
|
|
131
|
+
delete cslItem['collection-number'];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (entries.has(citationKey)) {
|
|
135
|
+
warnings.push(`${sourceLabel}: duplicate citation key "${citationKey}" within the same file; the later entry wins`);
|
|
136
|
+
}
|
|
137
|
+
entries.set(citationKey, cslItem);
|
|
138
|
+
}
|
|
139
|
+
return { entries, warnings };
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Merge a later file's entries over an earlier file's, by citation key.
|
|
143
|
+
* Mirrors autoterm's `mergeTerminology`: an override-by-key merge, not a
|
|
144
|
+
* deep field-level merge, matching the shared local-content-and-overrides
|
|
145
|
+
* design every extension in this codebase already uses.
|
|
146
|
+
*/
|
|
147
|
+
function mergeCiteRegistry(base, overlay) {
|
|
148
|
+
const merged = new Map(base);
|
|
149
|
+
const overridden = [];
|
|
150
|
+
for (const [key, entry] of overlay) {
|
|
151
|
+
if (merged.has(key))
|
|
152
|
+
overridden.push(key);
|
|
153
|
+
merged.set(key, entry);
|
|
154
|
+
}
|
|
155
|
+
return { merged, overridden };
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/extensions/cite-it/registry.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;;AA6EH,sCA0EC;AAQD,8CAWC;AAxKD,uEAAuE;AACvE,4EAA4E;AAC5E,6EAA6E;AAC7E,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,oCAAoC;AACpC,MAAM,YAAY,GAAG,OAAO,CAAC,wBAAwB,CAAC,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AE,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -142,9 +142,36 @@ interface ContentAggregateItem {
|
|
|
142
142
|
version: string;
|
|
143
143
|
ext?: Record<string, Record<string, unknown>>;
|
|
144
144
|
}
|
|
145
|
+
interface ResourceIdContext {
|
|
146
|
+
component?: string;
|
|
147
|
+
version?: string;
|
|
148
|
+
module?: string;
|
|
149
|
+
family?: string;
|
|
150
|
+
relative?: string;
|
|
151
|
+
}
|
|
152
|
+
interface ComponentVersionEntry {
|
|
153
|
+
name?: string;
|
|
154
|
+
version?: string;
|
|
155
|
+
asciidoc?: {
|
|
156
|
+
attributes?: Record<string, unknown>;
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
interface ComponentEntry {
|
|
160
|
+
name: string;
|
|
161
|
+
versions: ComponentVersionEntry[];
|
|
162
|
+
}
|
|
145
163
|
interface ContentCatalog {
|
|
146
164
|
getFiles: () => VirtualFile[];
|
|
147
165
|
addFile: (file: VirtualFile) => void;
|
|
166
|
+
/** Antora's own resource-ID resolver; see collectIncludeText. */
|
|
167
|
+
resolveResource?: (spec: string, context?: ResourceIdContext, defaultFamily?: string, permittedFamilies?: string[]) => VirtualFile | undefined;
|
|
168
|
+
/** Antora's own by-path lookup; see collectIncludeText. */
|
|
169
|
+
getByPath?: (criteria: {
|
|
170
|
+
component?: string;
|
|
171
|
+
version?: string;
|
|
172
|
+
path: string;
|
|
173
|
+
}) => VirtualFile | undefined;
|
|
174
|
+
getComponents?: () => ComponentEntry[];
|
|
148
175
|
}
|
|
149
176
|
interface Registry {
|
|
150
177
|
getLogger?: (name: string) => AntoraLogger;
|
|
@@ -179,7 +206,50 @@ export declare function mergeTrademarks(globalTrademarks: Map<string, TrademarkE
|
|
|
179
206
|
merged: Map<string, TrademarkEntry>;
|
|
180
207
|
overridden: string[];
|
|
181
208
|
};
|
|
182
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Strip AsciiDoc content that should not be scanned for trademarks: single-
|
|
211
|
+
* line comments, and unsatisfied ifdef::/ifndef:: conditional blocks
|
|
212
|
+
* evaluated against real attribute state.
|
|
213
|
+
*
|
|
214
|
+
* Delegates conditional evaluation to the shared, real-Asciidoctor-backed
|
|
215
|
+
* evaluator in src/lib/asciidoc-conditionals.ts (see
|
|
216
|
+
* agent-memory/trademark-it-project.md) rather than the ignore-list-only
|
|
217
|
+
* model this function used before it: an ifdef:: block now survives only
|
|
218
|
+
* when its attribute expression is genuinely satisfied, an ifndef:: block
|
|
219
|
+
* only when it genuinely is not — previously both were kept unconditionally
|
|
220
|
+
* regardless of real state, and only an ifdef:: block could be force-
|
|
221
|
+
* suppressed via ignoreConditionals (that force-list still works the same
|
|
222
|
+
* way; it now layers on top of real evaluation instead of being the only
|
|
223
|
+
* mechanism). ifeval:: content is kept, since expressions are not
|
|
224
|
+
* evaluated, matching the shared evaluator's own documented contract.
|
|
225
|
+
* Block comments (////) are now also handled by the shared evaluator's own
|
|
226
|
+
* real reader, which recognizes them natively; this function no longer
|
|
227
|
+
* tracks them itself.
|
|
228
|
+
*
|
|
229
|
+
* `isDefined` defaults to "nothing is defined": calling this without real
|
|
230
|
+
* attribute state to offer is conservative (an ifdef:: block is hidden, an
|
|
231
|
+
* ifndef:: block is shown) rather than reproducing the old "always keep"
|
|
232
|
+
* default, which was never actually correct.
|
|
233
|
+
*
|
|
234
|
+
* Comments, single-line and block, are stripped by this function itself,
|
|
235
|
+
* not the shared evaluator: verified empirically (not assumed) that
|
|
236
|
+
* Asciidoctor's raw preprocessor reader — `parse: false`, what the shared
|
|
237
|
+
* evaluator uses — does not recognize a `////` block comment as a unit at
|
|
238
|
+
* all. Block-comment recognition turned out to be a parser-level concern,
|
|
239
|
+
* only correctly handled during a full parse (confirmed separately for the
|
|
240
|
+
* real converter autoterm's indexterm scanner uses, which is unaffected).
|
|
241
|
+
* A directive-like line sitting inside an unstripped block comment would
|
|
242
|
+
* otherwise still be evaluated for real by the shared evaluator, corrupting
|
|
243
|
+
* content that is supposed to be entirely inert — caught by this file's own
|
|
244
|
+
* test suite, not assumed correct from Phase 2's autoterm work.
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* Blanks `//` and `////`-delimited comment lines, preserving line count.
|
|
248
|
+
* Exported for cite-it, a second consumer that needs the same stripping
|
|
249
|
+
* before scanning page text for `citeit:[key]` usage.
|
|
250
|
+
*/
|
|
251
|
+
export declare function stripComments(text: string): string;
|
|
252
|
+
export declare function stripNonContent(text: string, isDefined?: (attr: string) => boolean, ignoreConditionals?: string[]): string;
|
|
183
253
|
export declare function extractSvgText(svgSource: string): string;
|
|
184
254
|
/**
|
|
185
255
|
* Scan source text for trademark terms. Returns a map of matched canonical
|
|
@@ -187,7 +257,7 @@ export declare function extractSvgText(svgSource: string): string;
|
|
|
187
257
|
* terms that were actually found. Every member of a group is tested so that
|
|
188
258
|
* buildable declarations can be assembled from only the terms present.
|
|
189
259
|
*/
|
|
190
|
-
export declare function findTrademarks(sourceText: string, trademarks: Map<string, TrademarkEntry>, ignoreConditionals?: string[]): Map<string, Set<string>>;
|
|
260
|
+
export declare function findTrademarks(sourceText: string, trademarks: Map<string, TrademarkEntry>, isDefined?: (attr: string) => boolean, ignoreConditionals?: string[]): Map<string, Set<string>>;
|
|
191
261
|
/**
|
|
192
262
|
* Generate the content of the injected partial.
|
|
193
263
|
*
|
|
@@ -197,24 +267,6 @@ export declare function findTrademarks(sourceText: string, trademarks: Map<strin
|
|
|
197
267
|
* are ordered as a file manager would present them.
|
|
198
268
|
*/
|
|
199
269
|
export declare function generateTrademarkPartial(foundBaseTerms: Map<string, Set<string>>, trademarks: Map<string, TrademarkEntry>, cols?: string, leftCol?: 'combined' | 'primary', rowSpacing?: boolean): string;
|
|
200
|
-
/**
|
|
201
|
-
* Parse an Antora resource ID from an include:: directive target.
|
|
202
|
-
*
|
|
203
|
-
* Supported formats:
|
|
204
|
-
* [version@][component:][module:]family$relative
|
|
205
|
-
* [version@][component:]module:relative (implicit family, family = '')
|
|
206
|
-
*
|
|
207
|
-
* Missing parts fall back to the provided context defaults. An empty family
|
|
208
|
-
* tells the catalog lookup to match any family.
|
|
209
|
-
* Returns null for plain filesystem paths (no '$' and no ':' present).
|
|
210
|
-
*/
|
|
211
|
-
export declare function parseIncludeTarget(target: string, defaultComponent: string, defaultVersion: string, defaultModule: string): {
|
|
212
|
-
component: string;
|
|
213
|
-
version: string;
|
|
214
|
-
module: string;
|
|
215
|
-
family: string;
|
|
216
|
-
relative: string;
|
|
217
|
-
} | null;
|
|
218
270
|
/**
|
|
219
271
|
* Resolve a plain relative include target against the including file's
|
|
220
272
|
* catalog path, mirroring Asciidoctor's resolution of filesystem-style
|
|
@@ -242,12 +294,22 @@ export declare function applyIncludeFilters(text: string, attrlist: string): str
|
|
|
242
294
|
* Recursively collect the text of all files referenced via include:: directives
|
|
243
295
|
* in `sourceText`, looking each up in the content catalog.
|
|
244
296
|
*
|
|
297
|
+
* File resolution delegates to Antora's own ContentCatalog#resolveResource
|
|
298
|
+
* (resource-ID targets: version@, component:module:family$relative, and the
|
|
299
|
+
* familyless page-shorthand form) and #getByPath (plain relative targets,
|
|
300
|
+
* resolved against `currentPath` first). See
|
|
301
|
+
* agent-memory/autoterm-trademark-it-api-rewrite-scope.md (Phase 3) for why:
|
|
302
|
+
* both are Antora's real, public, documented resolution logic, not a
|
|
303
|
+
* reimplementation of its resource-ID grammar. Everything else here —
|
|
304
|
+
* recursion, cycle/dedup tracking via `visited`, tag=/tags=/lines= filtering
|
|
305
|
+
* via applyIncludeFilters — is unchanged; only file lookup moved.
|
|
306
|
+
*
|
|
245
307
|
* `visited` prevents revisiting files already being scanned or already resolved
|
|
246
308
|
* in a previous recursion step. Callers should pre-populate it with the keys
|
|
247
309
|
* of all files already in the main scan set.
|
|
248
310
|
*
|
|
249
|
-
* Cross-component includes without an explicit version@ prefix
|
|
250
|
-
*
|
|
311
|
+
* Cross-component includes without an explicit version@ prefix resolve to
|
|
312
|
+
* that component's latest version, per resolveResource's own semantics.
|
|
251
313
|
*
|
|
252
314
|
* `scanExclude` glob patterns (same as the top-level scan_exclude config) are
|
|
253
315
|
* applied to each resolved file's path. Matched files are skipped and added to
|
|
@@ -264,5 +326,12 @@ export declare function applyIncludeFilters(text: string, attrlist: string): str
|
|
|
264
326
|
*/
|
|
265
327
|
export declare function collectIncludeText(sourceText: string, contentCatalog: ContentCatalog, defaultComponent: string, defaultVersion: string, defaultModule: string, visited: Set<string>, scanExclude?: string[], onFile?: (chain: string[], content: string) => void, _chain?: string[], currentPath?: string): string;
|
|
266
328
|
export declare function register(this: Registry, context?: Registry): void;
|
|
329
|
+
/**
|
|
330
|
+
* Derive the set of unique component-version pairs from the catalog.
|
|
331
|
+
* Returns a Map<component, Set<version>>. Exported for cite-it, a third
|
|
332
|
+
* consumer of this same enumeration (autoterm still builds its own inline,
|
|
333
|
+
* a known small duplication; see root CLAUDE.md, "Content Extraction").
|
|
334
|
+
*/
|
|
335
|
+
export declare function getComponentVersions(contentCatalog: ContentCatalog): Map<string, Set<string>>;
|
|
267
336
|
export {};
|
|
268
337
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/trademark-it/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/trademark-it/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAYH,UAAU,iBAAiB;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,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