@baiyibai-antora/extensions 1.18.5 → 1.19.1
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 +25 -0
- package/dist/extensions/cite-it/assembly-numbering.d.ts +42 -25
- package/dist/extensions/cite-it/assembly-numbering.d.ts.map +1 -1
- package/dist/extensions/cite-it/assembly-numbering.js +44 -32
- package/dist/extensions/cite-it/assembly-numbering.js.map +1 -1
- package/dist/extensions/cite-it/csl.d.ts +36 -8
- package/dist/extensions/cite-it/csl.d.ts.map +1 -1
- package/dist/extensions/cite-it/csl.js +138 -33
- package/dist/extensions/cite-it/csl.js.map +1 -1
- package/dist/extensions/cite-it/index.d.ts +28 -8
- package/dist/extensions/cite-it/index.d.ts.map +1 -1
- package/dist/extensions/cite-it/index.js +206 -69
- package/dist/extensions/cite-it/index.js.map +1 -1
- package/dist/extensions/cite-it/macro.d.ts +11 -0
- package/dist/extensions/cite-it/macro.d.ts.map +1 -1
- package/dist/extensions/cite-it/macro.js +1 -0
- package/dist/extensions/cite-it/macro.js.map +1 -1
- package/package.json +1 -1
- package/resources/cite-it/author-date.csl +2273 -0
package/CHANGELOG.adoc
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
3
3
|
|
|
4
4
|
All notable changes to this project will be documented in this file.
|
|
5
5
|
|
|
6
|
+
== [1.19.1] - 2026-09-01
|
|
7
|
+
|
|
8
|
+
=== Fixed
|
|
9
|
+
|
|
10
|
+
* cite-it: citeproc-js expands a real trademark (™) or service mark (℠) character found in ANY `.bib` field (title, publisher, container-title, confirmed directly, not title-only) into `<sup>TM</sup>`/`<sup>SM</sup>` in its own output, in both bundled styles, unconditionally, losing the real character entirely: `htmlEntryToAsciiDoc`'s own generic `<sup>` handling then faithfully preserved citeproc's literal "TM"/"SM" text instead of the real character it replaced. A document's own real ™ silently became different, differently-searchable text in the rendered bibliography, independent of the `superscript_symbols` setting, reported directly against a real title. `htmlEntryToAsciiDoc` now recognizes citeproc's own `<sup>TM</sup>`/`<sup>SM</sup>` shape specifically and restores the real character, still wrapped in AsciiDoc superscript markup, unconditionally, a data-fidelity fix independent of `superscript_symbols`. `superscriptTrademarkSymbols` (the opt-in pass covering ®/©, which citeproc never touches) no longer matches ™/℠ at all, avoiding a double-wrap of the now-already-restored character when `superscript_symbols` is enabled.
|
|
11
|
+
|
|
12
|
+
== [1.19.0] - 2026-08-31
|
|
13
|
+
|
|
14
|
+
=== Added
|
|
15
|
+
|
|
16
|
+
* cite-it: a new `author-date` `style`, a real, complete, unmodified APA 7th edition CSL style (`resources/cite-it/author-date.csl`, fetched from the official `citation-style-language/styles` repository, same CC-BY-SA licensing convention `ieee-bracket.csl` already carries), alongside the existing `ieee-bracket` (numeric). `csl.ts` exposes `citationFormatFor(style)`, reading each bundled style's own real CSL `<category citation-format="...">` metadata rather than a hand-maintained parallel table.
|
|
17
|
+
* cite-it: the citation-format `style` selects now drives the inline `cite:[key]` marker's own shape in BOTH ordinary HTML and PDF/assembled output, not just the bibliography list. `ieee-bracket` (numeric, the default) means true first-appearance `[N]` markers, linked, on HTML too now, reusing the exact same real, navigation-order numbering PDF output has always used, not a fresh per-page count: a key cited from page to page carries one consistent number everywhere. `author-date` is new for PDF/assembled output: Ruby's `asciidoctor-pdf` subprocess never loads this package's live macro, so its markers, and the bibliography partial's own row label, get the same pre-rewrite-before-parse treatment numeric markers always needed.
|
|
18
|
+
* cite-it: the generated bibliography partial's row order now matches what each citation-format's reader actually needs to look an entry up: ascending citation-number order for `numeric` (unchanged), first-author-name alphabetical order for `author-date` (previously always sorted by internal citation key, an identifier a reader never sees).
|
|
19
|
+
|
|
20
|
+
=== Changed
|
|
21
|
+
|
|
22
|
+
* cite-it: `style` is now a playbook-wide setting only, applied identically to every participating component version's HTML, PDF, and Confluence/ADF output. It is no longer overridable per component version: a component version's own `ext.cite_it.style`, if still present, is ignored, with a build warning naming the ignored value. The inline citation marker and the bibliography entry it points at must share one citation-format convention for a reader to look an entry up at all (a numeric marker needs a numerically ordered list; an author-date marker needs an author-ordered one), a constraint that holds site-wide, not per component version.
|
|
23
|
+
* cite-it: with the playbook-wide default (`ieee-bracket`, unchanged), ordinary HTML output now renders `[N]` citation markers by default, matching PDF output, instead of the previous `(Author, Year)` fallback. This changes default rendered HTML output for every existing site using cite-it with no `style` configured; set `style: 'author-date'` to keep the previous look.
|
|
24
|
+
* cite-it: the generated bibliography partial's row-label rewrite for a `numeric`-style citation is no longer restored before the next ordinary (HTML, or Confluence/ADF export) `loadAsciiDoc` call reads it. `style` being playbook-wide means every consumer wants the identical rewritten partial now; the restore mechanism 1.18.4 added specifically because PDF and ordinary output used to want different content for the same partial no longer has a scenario to guard against.
|
|
25
|
+
* cite-it: `formatBibliographyEntries`'s underlying citeproc `Engine` is now constructed once per style and reused for every later call, instead of being rebuilt (recompiling the whole CSL style document) on every call. Confirmed to be the entire real cost of a `formatBibliographyEntries` call, independent of item count: ~76ms to construct for `ieee-bracket.csl`, ~1.3s for the real, complete `author-date.csl` (99 macros, 252 conditional branches against `ieee-bracket.csl`'s 15 and 36), profiled directly to `CSL.XmlJSON.getNodesByName`, citeproc-js's own unindexed full-tree-rescan on every macro-name lookup, not the actual formatting work (`updateItems`/`makeBibliography` alone are consistently single-digit milliseconds regardless of style). Reuse safety (no disambiguation-state leakage between two component-versions sharing one cached engine) verified directly, not assumed, and locked in with a test.
|
|
26
|
+
|
|
27
|
+
=== Fixed
|
|
28
|
+
|
|
29
|
+
* cite-it: `loadAsciiDocWrapper`'s own assembled-output detection checked only whether `asciidocConfig.attributes` carried the key `'loader-assembler'`, not its value, unlike `registerCiteMacro`'s equivalent, correct `doc.hasAttribute('loader-assembler')` check, which treats an attribute explicitly set to `false` as unset. A toolchain that declares `loader-assembler` as a default `asciidoc.attributes` entry, even set to `false`, satisfied the old check on every single page load, assembled or not, independent of whether Antora Assembler ever actually ran, reported directly with a reproduction.
|
|
30
|
+
|
|
6
31
|
== [1.18.5] - 2026-08-31
|
|
7
32
|
|
|
8
33
|
=== Fixed
|
|
@@ -182,8 +182,7 @@ export declare function reorderBibliographyRows(text: string, numbers: Map<strin
|
|
|
182
182
|
/**
|
|
183
183
|
* Rewrites the generated bibliography partial's OWN `cite:[key]` row
|
|
184
184
|
* labels to their final `[N]` numbers, mutating the file directly in the
|
|
185
|
-
* content catalog
|
|
186
|
-
* changed.
|
|
185
|
+
* content catalog.
|
|
187
186
|
*
|
|
188
187
|
* Needed for a reason distinct from rewriteCiteMarkers' normal call site:
|
|
189
188
|
* Antora's own include processor resolves an `include::partial$...[]`
|
|
@@ -194,31 +193,49 @@ export declare function reorderBibliographyRows(text: string, numbers: Map<strin
|
|
|
194
193
|
* rewrite text that arrives via an include inside that parse; a citing
|
|
195
194
|
* page's own `cite:[key]` usage rewrites correctly, but the generated
|
|
196
195
|
* partial's own row labels, pulled in during the same parse, would
|
|
197
|
-
* otherwise reach Ruby unrewritten
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
196
|
+
* otherwise reach Ruby unrewritten (for PDF) or reach registerCiteMacro's
|
|
197
|
+
* own live rendering, which has no reliable way to know the true,
|
|
198
|
+
* cross-page-computed number a per-document counter alone would not
|
|
199
|
+
* necessarily match. Called once per component-version, before any
|
|
200
|
+
* loadAsciiDoc call that needs `numbers` can run (synchronous, from
|
|
201
|
+
* ensureAssemblyDataComputed), so the partial is already correct by the
|
|
202
|
+
* time anything tries to include it.
|
|
201
203
|
*
|
|
202
|
-
* The mutation
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
204
|
+
* The mutation is never restored, deliberately, as of the `style`-is-
|
|
205
|
+
* playbook-wide-only redesign: `style` (and therefore, via
|
|
206
|
+
* citationFormatFor, whether numeric numbering applies at all) is now the
|
|
207
|
+
* SAME single value for every consumer of this partial, ordinary HTML,
|
|
208
|
+
* PDF/assembled, and Confluence/ADF export alike, so there is no longer a
|
|
209
|
+
* competing "the next reader wants something different" case to guard
|
|
210
|
+
* against. An EARLIER version of this function returned a restore
|
|
211
|
+
* function per changed partial, undone at the start of the next ordinary
|
|
212
|
+
* loadAsciiDoc call specifically because PDF assembly used to always want
|
|
213
|
+
* `[N]` while ordinary/Confluence output always wanted `(Author, Year)`
|
|
214
|
+
* for the exact same partial; confirmed live, without that restore, the
|
|
215
|
+
* demo site's own published Confluence page once showed the assembled
|
|
216
|
+
* `[1]` label instead. That divergence cannot happen anymore: whichever
|
|
217
|
+
* citation-format `style` resolves to, every consumer wants the identical
|
|
218
|
+
* rewritten (or, for a non-numeric style, entirely untouched, since this
|
|
219
|
+
* function is only ever called when numeric numbering applies) partial
|
|
220
|
+
* content.
|
|
215
221
|
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
222
|
+
* For the `numeric` citation-format only, also reorders the partial's rows
|
|
223
|
+
* into ascending citation-number order (reorderBibliographyRows) before
|
|
224
|
+
* rewriting labels: the order the partial was generated in has no
|
|
225
|
+
* relationship to citation number (Node does not know numbers yet at
|
|
226
|
+
* generation time), and a numbered bibliography listed out of number order
|
|
227
|
+
* reads as broken to anyone looking at it. A non-numeric citation-format
|
|
228
|
+
* needs no second reorder pass here: index.ts's own row-generation already
|
|
229
|
+
* sorts by author for that case, a real ordering known at generation time,
|
|
230
|
+
* unlike citation number.
|
|
231
|
+
*
|
|
232
|
+
* `labelFor` decouples this function from numeric numbering specifically:
|
|
233
|
+
* the caller supplies whichever label shape the active `style`'s citation-
|
|
234
|
+
* format implies (numberLabels for `numeric`, formatHtmlLabels-shaped
|
|
235
|
+
* author/year text for `author-date`), the same function it uses to
|
|
236
|
+
* rewrite the CITING page's own markers, so the row label and the marker
|
|
237
|
+
* pointing at it always agree.
|
|
221
238
|
*/
|
|
222
|
-
export declare function rewritePartialForAssembly(ctx: ScanContext, numbers: Map<string, number
|
|
239
|
+
export declare function rewritePartialForAssembly(ctx: ScanContext, numbers: Map<string, number>, reorderByNumber: boolean, labelFor: (key: string) => string | undefined): void;
|
|
223
240
|
export {};
|
|
224
241
|
//# sourceMappingURL=assembly-numbering.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assembly-numbering.d.ts","sourceRoot":"","sources":["../../../src/extensions/cite-it/assembly-numbering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAcH,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;CACzC;AAED,UAAU,WAAW;IACnB,GAAG,EAAE,cAAc,CAAC;IACpB,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACxB;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,WAAW,EAAE,CAAC;IAC9B,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MA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AAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,EAC7C,MAAM,UAAO,EACb,MAAM,GAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAW,GACxC,MAAM,CAsCR;AAED;;;;;mDAKmD;AACnD,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAK9F;AA0BD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CA2B1F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,eAAe,EAAE,OAAO,EACxB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC5C,IAAI,CAiBN"}
|
|
@@ -365,8 +365,7 @@ function reorderBibliographyRows(text, numbers) {
|
|
|
365
365
|
/**
|
|
366
366
|
* Rewrites the generated bibliography partial's OWN `cite:[key]` row
|
|
367
367
|
* labels to their final `[N]` numbers, mutating the file directly in the
|
|
368
|
-
* content catalog
|
|
369
|
-
* changed.
|
|
368
|
+
* content catalog.
|
|
370
369
|
*
|
|
371
370
|
* Needed for a reason distinct from rewriteCiteMarkers' normal call site:
|
|
372
371
|
* Antora's own include processor resolves an `include::partial$...[]`
|
|
@@ -377,35 +376,50 @@ function reorderBibliographyRows(text, numbers) {
|
|
|
377
376
|
* rewrite text that arrives via an include inside that parse; a citing
|
|
378
377
|
* page's own `cite:[key]` usage rewrites correctly, but the generated
|
|
379
378
|
* partial's own row labels, pulled in during the same parse, would
|
|
380
|
-
* otherwise reach Ruby unrewritten
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
379
|
+
* otherwise reach Ruby unrewritten (for PDF) or reach registerCiteMacro's
|
|
380
|
+
* own live rendering, which has no reliable way to know the true,
|
|
381
|
+
* cross-page-computed number a per-document counter alone would not
|
|
382
|
+
* necessarily match. Called once per component-version, before any
|
|
383
|
+
* loadAsciiDoc call that needs `numbers` can run (synchronous, from
|
|
384
|
+
* ensureAssemblyDataComputed), so the partial is already correct by the
|
|
385
|
+
* time anything tries to include it.
|
|
384
386
|
*
|
|
385
|
-
* The mutation
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
387
|
+
* The mutation is never restored, deliberately, as of the `style`-is-
|
|
388
|
+
* playbook-wide-only redesign: `style` (and therefore, via
|
|
389
|
+
* citationFormatFor, whether numeric numbering applies at all) is now the
|
|
390
|
+
* SAME single value for every consumer of this partial, ordinary HTML,
|
|
391
|
+
* PDF/assembled, and Confluence/ADF export alike, so there is no longer a
|
|
392
|
+
* competing "the next reader wants something different" case to guard
|
|
393
|
+
* against. An EARLIER version of this function returned a restore
|
|
394
|
+
* function per changed partial, undone at the start of the next ordinary
|
|
395
|
+
* loadAsciiDoc call specifically because PDF assembly used to always want
|
|
396
|
+
* `[N]` while ordinary/Confluence output always wanted `(Author, Year)`
|
|
397
|
+
* for the exact same partial; confirmed live, without that restore, the
|
|
398
|
+
* demo site's own published Confluence page once showed the assembled
|
|
399
|
+
* `[1]` label instead. That divergence cannot happen anymore: whichever
|
|
400
|
+
* citation-format `style` resolves to, every consumer wants the identical
|
|
401
|
+
* rewritten (or, for a non-numeric style, entirely untouched, since this
|
|
402
|
+
* function is only ever called when numeric numbering applies) partial
|
|
403
|
+
* content.
|
|
398
404
|
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
405
|
+
* For the `numeric` citation-format only, also reorders the partial's rows
|
|
406
|
+
* into ascending citation-number order (reorderBibliographyRows) before
|
|
407
|
+
* rewriting labels: the order the partial was generated in has no
|
|
408
|
+
* relationship to citation number (Node does not know numbers yet at
|
|
409
|
+
* generation time), and a numbered bibliography listed out of number order
|
|
410
|
+
* reads as broken to anyone looking at it. A non-numeric citation-format
|
|
411
|
+
* needs no second reorder pass here: index.ts's own row-generation already
|
|
412
|
+
* sorts by author for that case, a real ordering known at generation time,
|
|
413
|
+
* unlike citation number.
|
|
414
|
+
*
|
|
415
|
+
* `labelFor` decouples this function from numeric numbering specifically:
|
|
416
|
+
* the caller supplies whichever label shape the active `style`'s citation-
|
|
417
|
+
* format implies (numberLabels for `numeric`, formatHtmlLabels-shaped
|
|
418
|
+
* author/year text for `author-date`), the same function it uses to
|
|
419
|
+
* rewrite the CITING page's own markers, so the row label and the marker
|
|
420
|
+
* pointing at it always agree.
|
|
404
421
|
*/
|
|
405
|
-
function rewritePartialForAssembly(ctx, numbers) {
|
|
406
|
-
const restores = [];
|
|
407
|
-
if (numbers.size === 0)
|
|
408
|
-
return restores;
|
|
422
|
+
function rewritePartialForAssembly(ctx, numbers, reorderByNumber, labelFor) {
|
|
409
423
|
for (const cp of ctx.categoryPartials) {
|
|
410
424
|
const partial = ctx.contentCatalog.getFiles().find((f) => f.src.component === ctx.component &&
|
|
411
425
|
f.src.version === ctx.version &&
|
|
@@ -415,13 +429,11 @@ function rewritePartialForAssembly(ctx, numbers) {
|
|
|
415
429
|
if (!partial)
|
|
416
430
|
continue;
|
|
417
431
|
const before = partial.contents.toString('utf8');
|
|
418
|
-
const reordered = reorderBibliographyRows(before, numbers);
|
|
419
|
-
const after = rewriteCiteMarkers(reordered,
|
|
432
|
+
const reordered = reorderByNumber ? reorderBibliographyRows(before, numbers) : before;
|
|
433
|
+
const after = rewriteCiteMarkers(reordered, labelFor, false);
|
|
420
434
|
if (after === before)
|
|
421
435
|
continue;
|
|
422
436
|
partial.contents = Buffer.from(after, 'utf8');
|
|
423
|
-
restores.push(() => { partial.contents = Buffer.from(before, 'utf8'); });
|
|
424
437
|
}
|
|
425
|
-
return restores;
|
|
426
438
|
}
|
|
427
439
|
//# sourceMappingURL=assembly-numbering.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assembly-numbering.js","sourceRoot":"","sources":["../../../src/extensions/cite-it/assembly-numbering.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;AAsIH,wDAyEC;AAiBD,wDAsBC;AA0ED,gDA2CC;AAQD,oCAKC;AA0BD,0DA2BC;
|
|
1
|
+
{"version":3,"file":"assembly-numbering.js","sourceRoot":"","sources":["../../../src/extensions/cite-it/assembly-numbering.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;AAsIH,wDAyEC;AAiBD,wDAsBC;AA0ED,gDA2CC;AAQD,oCAKC;AA0BD,0DA2BC;AA2DD,8DAsBC;AA5fD,mCAA8C;AAC9C,iDAA4E;AAC5E,6CAAoD;AACpD,2EAAuE;AACvE,uEAAgE;AA+ChE,8EAA8E;AAC9E,yEAAyE;AACzE,wEAAwE;AACxE,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,2EAA2E;AAC3E,2EAA2E;AAC3E,oBAAoB;AACpB,8EAA8E;AAE9E,SAAS,0BAA0B,CAAC,OAAsC,EAAE,IAAiB,EAAE,GAAa;IAC1G,KAAK,MAAM,KAAK,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;QAClC,IAAI,KAAK,CAAC,OAAO,KAAK,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;YACnE,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,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;;;;;;;;;;GAwDG;AACH,SAAgB,yBAAyB,CACvC,GAAgB,EAChB,OAA4B,EAC5B,eAAwB,EACxB,QAA6C;IAE7C,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,GAAG,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,IAAI,CAChD,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,SAAS;YACjC,CAAC,CAAC,GAAG,CAAC,OAAO,KAAK,GAAG,CAAC,OAAO;YAC7B,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,SAAS;YAC1B,CAAC,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;YAC3B,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAC,QAAQ,CACjC,CAAC;QACF,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,SAAS,GAAG,eAAe,CAAC,CAAC,CAAC,uBAAuB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtF,MAAM,KAAK,GAAG,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7D,IAAI,KAAK,KAAK,MAAM;YAAE,SAAS;QAC/B,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -13,16 +13,44 @@
|
|
|
13
13
|
* partial's row label (macro.ts), so the two numbering sources agree by
|
|
14
14
|
* construction rather than by cross-checking two independent counters.
|
|
15
15
|
*
|
|
16
|
-
* `STYLES`
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
16
|
+
* `STYLES` bundles two real, unmodified, standard CSL styles fetched from
|
|
17
|
+
* the official citation-style-language/styles repository, the same CC-BY-SA
|
|
18
|
+
* licensing convention both files carry in their own `<info><rights>`:
|
|
19
|
+
* `ieee-bracket` (numeric) and `author-date` (a real, complete APA 7th
|
|
20
|
+
* edition style, not a hand-authored approximation of "an author-date
|
|
21
|
+
* style" - CSL's own `author-date` category covers several genuinely
|
|
22
|
+
* different concrete conventions, APA chosen as the most broadly
|
|
23
|
+
* recognized one). Adding a style is a matter of shipping its `.csl` file
|
|
24
|
+
* under `resources/cite-it/` and one new `STYLES` entry (`citationFormat`
|
|
25
|
+
* included, see `CitationFormat`/`citationFormatFor` below), not a design
|
|
26
|
+
* change. A `style` value not present in `STYLES` is rejected with a clear
|
|
27
|
+
* error rather than silently falling back, since a silently wrong citation
|
|
28
|
+
* style is a worse failure than a build error naming the actual gap.
|
|
24
29
|
*/
|
|
25
30
|
import type { CslJsonItem } from './registry';
|
|
31
|
+
/**
|
|
32
|
+
* `citationFormat` mirrors each style's own real CSL `<category
|
|
33
|
+
* citation-format="...">` metadata (confirmed directly in both bundled
|
|
34
|
+
* files: `ieee-bracket.csl` declares `numeric`, `author-date.csl` declares
|
|
35
|
+
* `author-date`), declared here rather than parsed from the XML at load
|
|
36
|
+
* time: the value drives real branching elsewhere in cite-it (which inline
|
|
37
|
+
* marker shape a style produces, how the generated bibliography partial's
|
|
38
|
+
* own rows are ordered), so it needs to be known synchronously, cheaply,
|
|
39
|
+
* and without adding an XML-attribute-extraction dependency for one field.
|
|
40
|
+
* A style bundled here always keeps its own XML `<category>` tag in sync,
|
|
41
|
+
* the normal CSL-authoring convention, but that tag itself is descriptive
|
|
42
|
+
* metadata only; this declaration is what code actually reads.
|
|
43
|
+
*/
|
|
44
|
+
export type CitationFormat = 'numeric' | 'author-date';
|
|
45
|
+
/**
|
|
46
|
+
* The citation-format a `style` config value resolves to, for callers that
|
|
47
|
+
* need to know which inline-marker/bibliography-ordering rules to apply
|
|
48
|
+
* without loading the full citeproc Engine. Throws the same clear,
|
|
49
|
+
* unsupported-style error `loadEngine` does, rather than defaulting
|
|
50
|
+
* silently: an unrecognized style name is a real misconfiguration either
|
|
51
|
+
* way, whichever entry point first notices it.
|
|
52
|
+
*/
|
|
53
|
+
export declare function citationFormatFor(styleName: string): CitationFormat;
|
|
26
54
|
/**
|
|
27
55
|
* Convert one citeproc bibliography entry's raw HTML fragment into AsciiDoc
|
|
28
56
|
* inline text. citeproc's output shape is two sibling <div>s per entry:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csl.d.ts","sourceRoot":"","sources":["../../../src/extensions/cite-it/csl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"csl.d.ts","sourceRoot":"","sources":["../../../src/extensions/cite-it/csl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAK9C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,aAAa,CAAC;AAOvD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAQnE;AAqFD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAiC7D;AA6HD,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAC/B,IAAI,EAAE,MAAM,EAAE,EACd,eAAe,UAAQ,EACvB,kBAAkB,UAAQ,EAC1B,UAAU,SAAK,GACd,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA2CrB"}
|
|
@@ -14,14 +14,19 @@
|
|
|
14
14
|
* partial's row label (macro.ts), so the two numbering sources agree by
|
|
15
15
|
* construction rather than by cross-checking two independent counters.
|
|
16
16
|
*
|
|
17
|
-
* `STYLES`
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
17
|
+
* `STYLES` bundles two real, unmodified, standard CSL styles fetched from
|
|
18
|
+
* the official citation-style-language/styles repository, the same CC-BY-SA
|
|
19
|
+
* licensing convention both files carry in their own `<info><rights>`:
|
|
20
|
+
* `ieee-bracket` (numeric) and `author-date` (a real, complete APA 7th
|
|
21
|
+
* edition style, not a hand-authored approximation of "an author-date
|
|
22
|
+
* style" - CSL's own `author-date` category covers several genuinely
|
|
23
|
+
* different concrete conventions, APA chosen as the most broadly
|
|
24
|
+
* recognized one). Adding a style is a matter of shipping its `.csl` file
|
|
25
|
+
* under `resources/cite-it/` and one new `STYLES` entry (`citationFormat`
|
|
26
|
+
* included, see `CitationFormat`/`citationFormatFor` below), not a design
|
|
27
|
+
* change. A `style` value not present in `STYLES` is rejected with a clear
|
|
28
|
+
* error rather than silently falling back, since a silently wrong citation
|
|
29
|
+
* style is a worse failure than a build error naming the actual gap.
|
|
25
30
|
*/
|
|
26
31
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
27
32
|
if (k2 === undefined) k2 = k;
|
|
@@ -57,6 +62,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
57
62
|
};
|
|
58
63
|
})();
|
|
59
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.citationFormatFor = citationFormatFor;
|
|
60
66
|
exports.htmlEntryToAsciiDoc = htmlEntryToAsciiDoc;
|
|
61
67
|
exports.formatBibliographyEntries = formatBibliographyEntries;
|
|
62
68
|
const fs = __importStar(require("node:fs"));
|
|
@@ -66,27 +72,87 @@ const date_fns_1 = require("date-fns");
|
|
|
66
72
|
const asciidoc_replacements_1 = require("../../lib/asciidoc-replacements");
|
|
67
73
|
const RESOURCES_DIR = path.join(__dirname, '..', '..', '..', 'resources', 'cite-it');
|
|
68
74
|
const STYLES = {
|
|
69
|
-
'ieee-bracket': { style: 'ieee-bracket.csl', locale: 'locale-en-US.xml' },
|
|
75
|
+
'ieee-bracket': { style: 'ieee-bracket.csl', locale: 'locale-en-US.xml', citationFormat: 'numeric' },
|
|
76
|
+
'author-date': { style: 'author-date.csl', locale: 'locale-en-US.xml', citationFormat: 'author-date' },
|
|
70
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* The citation-format a `style` config value resolves to, for callers that
|
|
80
|
+
* need to know which inline-marker/bibliography-ordering rules to apply
|
|
81
|
+
* without loading the full citeproc Engine. Throws the same clear,
|
|
82
|
+
* unsupported-style error `loadEngine` does, rather than defaulting
|
|
83
|
+
* silently: an unrecognized style name is a real misconfiguration either
|
|
84
|
+
* way, whichever entry point first notices it.
|
|
85
|
+
*/
|
|
86
|
+
function citationFormatFor(styleName) {
|
|
87
|
+
const spec = STYLES[styleName];
|
|
88
|
+
if (!spec) {
|
|
89
|
+
throw new Error(`cite-it: unknown style "${styleName}"; supported styles: ${Object.keys(STYLES).join(', ')}`);
|
|
90
|
+
}
|
|
91
|
+
return spec.citationFormat;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* One real `Engine` per style, constructed once and reused for every
|
|
95
|
+
* subsequent `formatBibliographyEntries` call in the same process,
|
|
96
|
+
* regardless of which component-version or item set is being formatted.
|
|
97
|
+
* `new Engine(sys, styleXml)` is where citeproc-js actually compiles the
|
|
98
|
+
* CSL style document into its own internal execution form, confirmed
|
|
99
|
+
* directly to be the entire real cost (timed independently of
|
|
100
|
+
* `updateItems`/`makeBibliography`, both consistently single-digit
|
|
101
|
+
* milliseconds regardless of style): ~76ms for `ieee-bracket.csl` (18KB),
|
|
102
|
+
* ~1.3s for the real, complete `author-date.csl` (86KB, over 100 macros).
|
|
103
|
+
* Reconstructing that from scratch per call, once per participating
|
|
104
|
+
* component-version, was real, avoidable per-build cost.
|
|
105
|
+
*
|
|
106
|
+
* Reuse is safe, not just fast, confirmed directly against citeproc-js's
|
|
107
|
+
* own real behavior, not assumed from its documentation: `engine.
|
|
108
|
+
* updateItems(keys)` fully replaces the engine's active item set on every
|
|
109
|
+
* call, including its disambiguation/registry state, byte-for-byte
|
|
110
|
+
* identical output to a fresh `Engine` given the same keys, verified by
|
|
111
|
+
* alternating between two different, independently colliding item sets on
|
|
112
|
+
* one shared engine and diffing against two separate fresh engines (no
|
|
113
|
+
* leakage of one component-version's disambiguation suffixes into
|
|
114
|
+
* another's, in either order). `itemsRef` exists only so each cached
|
|
115
|
+
* engine's own `retrieveItem` closure can be redirected to the CURRENT
|
|
116
|
+
* caller's items map on every call, since the closure itself is fixed at
|
|
117
|
+
* construction time but the underlying data is not.
|
|
118
|
+
*/
|
|
119
|
+
const engineCache = new Map();
|
|
71
120
|
function loadEngine(styleName, items) {
|
|
72
121
|
const spec = STYLES[styleName];
|
|
73
122
|
if (!spec) {
|
|
74
123
|
throw new Error(`cite-it: unknown style "${styleName}"; supported styles: ${Object.keys(STYLES).join(', ')}`);
|
|
75
124
|
}
|
|
125
|
+
const cached = engineCache.get(styleName);
|
|
126
|
+
if (cached) {
|
|
127
|
+
cached.itemsRef.current = items;
|
|
128
|
+
return cached.engine;
|
|
129
|
+
}
|
|
76
130
|
const styleXml = fs.readFileSync(path.join(RESOURCES_DIR, spec.style), 'utf8');
|
|
77
131
|
const localeXml = fs.readFileSync(path.join(RESOURCES_DIR, spec.locale), 'utf8');
|
|
132
|
+
const itemsRef = { current: items };
|
|
78
133
|
const sys = {
|
|
79
134
|
retrieveLocale: () => localeXml,
|
|
80
|
-
retrieveItem: (id) =>
|
|
135
|
+
retrieveItem: (id) => itemsRef.current.get(id),
|
|
81
136
|
};
|
|
82
|
-
|
|
137
|
+
const engine = new citeproc_1.Engine(sys, styleXml);
|
|
138
|
+
engineCache.set(styleName, { engine, itemsRef });
|
|
139
|
+
return engine;
|
|
83
140
|
}
|
|
84
141
|
/**
|
|
85
|
-
* Decode the
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
142
|
+
* Decode the HTML entities citeproc's own output uses. citeproc escapes
|
|
143
|
+
* text it renders (author names, titles) as HTML, since its native output
|
|
144
|
+
* target is a browser DOM; the generated partial is AsciiDoc, not HTML, so
|
|
145
|
+
* entities are decoded back to literal characters rather than left for
|
|
146
|
+
* AsciiDoc to interpret as markup.
|
|
147
|
+
*
|
|
148
|
+
* The small named-entity list was sufficient for `ieee-bracket.csl` alone
|
|
149
|
+
* (`and="text"` between co-authors, never a literal "&"), but a style using
|
|
150
|
+
* `and="symbol"` renders "&" as the NUMERIC entity `&`, not `&`
|
|
151
|
+
* (confirmed directly loading a real APA-style bibliography entry through
|
|
152
|
+
* citeproc: "Smith, J. A., & Nakamura, K."). Decimal and hex numeric
|
|
153
|
+
* character references are decoded generically, not just the one citeproc
|
|
154
|
+
* happens to emit today, so a future style choosing a different one still
|
|
155
|
+
* works without another silent gap.
|
|
90
156
|
*/
|
|
91
157
|
function decodeEntities(s) {
|
|
92
158
|
return s
|
|
@@ -94,8 +160,9 @@ function decodeEntities(s) {
|
|
|
94
160
|
.replace(/</g, '<')
|
|
95
161
|
.replace(/>/g, '>')
|
|
96
162
|
.replace(/"/g, '"')
|
|
97
|
-
.replace(
|
|
98
|
-
.replace(
|
|
163
|
+
.replace(/ /g, ' ')
|
|
164
|
+
.replace(/&#(\d+);/g, (_, dec) => String.fromCodePoint(Number(dec)))
|
|
165
|
+
.replace(/&#x([0-9a-fA-F]+);/g, (_, hex) => String.fromCodePoint(Number.parseInt(hex, 16)));
|
|
99
166
|
}
|
|
100
167
|
/**
|
|
101
168
|
* Convert one citeproc bibliography entry's raw HTML fragment into AsciiDoc
|
|
@@ -133,26 +200,61 @@ function htmlEntryToAsciiDoc(entryHtml) {
|
|
|
133
200
|
const withAsciidocMarkup = inner
|
|
134
201
|
.replace(/<i>([\s\S]*?)<\/i>/g, '_$1_')
|
|
135
202
|
.replace(/<b>([\s\S]*?)<\/b>/g, '*$1*')
|
|
203
|
+
// citeproc's own <sup>TM</sup>/<sup>SM</sup> is its own internal
|
|
204
|
+
// expansion of a real trademark (™) or service mark (℠) character
|
|
205
|
+
// found in the source data, in ANY field (title, publisher,
|
|
206
|
+
// container-title, confirmed directly, not title-only), never
|
|
207
|
+
// literal ASCII text a .bib entry actually wrote. Left to the
|
|
208
|
+
// generic <sup> rule below, which only knows to preserve whatever
|
|
209
|
+
// text citeproc put inside the tag, the real character is
|
|
210
|
+
// permanently lost, replaced by the plain letters "TM"/"SM": a real
|
|
211
|
+
// reported regression, a document's own real ™ silently became
|
|
212
|
+
// different, differently-searchable text in the rendered output.
|
|
213
|
+
// Restored here to the real character it always was, wrapped in
|
|
214
|
+
// AsciiDoc superscript markup the same way citeproc's own <sup>
|
|
215
|
+
// wrapping intended, unconditionally: this is a data-fidelity fix,
|
|
216
|
+
// not gated by superscript_symbols, the same "renders exactly as
|
|
217
|
+
// written" standard escapeAsciidocReplacements already holds
|
|
218
|
+
// .bib-derived text to below. superscriptTrademarkSymbols's own
|
|
219
|
+
// later, opt-in pass no longer touches ™/℠ at all (see its own
|
|
220
|
+
// docblock): this replacement already runs unconditionally, and
|
|
221
|
+
// running both would double-wrap.
|
|
222
|
+
.replace(/<sup>TM<\/sup>/g, '^™^')
|
|
223
|
+
.replace(/<sup>SM<\/sup>/g, '^℠^')
|
|
136
224
|
.replace(/<sup>([\s\S]*?)<\/sup>/g, '^$1^')
|
|
137
225
|
.replace(/<[^>]+>/g, '');
|
|
138
226
|
const plain = decodeEntities(withAsciidocMarkup).replace(/\s+/g, ' ').trim();
|
|
139
227
|
return (0, asciidoc_replacements_1.escapeAsciidocReplacements)(plain);
|
|
140
228
|
}
|
|
141
229
|
/**
|
|
142
|
-
* Wraps each
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
230
|
+
* Wraps each registered (®) and copyright (©) symbol found in `text` in
|
|
231
|
+
* AsciiDoc superscript markup, so it renders raised rather than sitting
|
|
232
|
+
* on the baseline. The symbol itself is data inside a `.bib` field
|
|
233
|
+
* (almost always a title, e.g. a product name), never something the CSL
|
|
234
|
+
* style has special handling for; this runs as a post-process over the
|
|
235
|
+
* already-formatted AsciiDoc text, the same shape blanketPubstate's own
|
|
236
|
+
* append already uses, rather than touching the style file. Verified
|
|
237
|
+
* directly against a real Asciidoctor conversion: the constrained
|
|
238
|
+
* single-caret form (`^®^`) renders correctly immediately adjacent to a
|
|
239
|
+
* preceding word character ("Widget^®^"), no space or unconstrained
|
|
240
|
+
* double-caret form needed.
|
|
241
|
+
*
|
|
242
|
+
* Deliberately does NOT match ™/℠ (unlike an earlier version of this
|
|
243
|
+
* function): those are already unconditionally restored to real
|
|
244
|
+
* characters, already wrapped in superscript markup, by
|
|
245
|
+
* `htmlEntryToAsciiDoc` itself, before this function ever runs (see its
|
|
246
|
+
* own docblock). A ™/℠ branch here would re-match the same character
|
|
247
|
+
* sitting inside that already-inserted `^...^` wrapper and double-wrap
|
|
248
|
+
* it (`^^™^^`), confirmed as the mechanism behind a real reported
|
|
249
|
+
* regression once `htmlEntryToAsciiDoc`'s own restoration stopped being
|
|
250
|
+
* silently defeated by citeproc's `<sup>TM</sup>`/`<sup>SM</sup>`
|
|
251
|
+
* character loss. ®/© never receive that citeproc-side treatment at all
|
|
252
|
+
* (confirmed directly, real characters pass through citeproc untouched
|
|
253
|
+
* in every field), so this function staying gated behind
|
|
254
|
+
* `superscript_symbols` remains correct for them specifically.
|
|
153
255
|
*/
|
|
154
256
|
function superscriptTrademarkSymbols(text) {
|
|
155
|
-
return text.replace(/([
|
|
257
|
+
return text.replace(/([®©])/gu, '^$1^');
|
|
156
258
|
}
|
|
157
259
|
/**
|
|
158
260
|
* Format bibliography-entry text for a set of CSL-JSON items, keyed by
|
|
@@ -169,9 +271,12 @@ function superscriptTrademarkSymbols(text) {
|
|
|
169
271
|
* render it.
|
|
170
272
|
*
|
|
171
273
|
* `superscriptSymbols`: cite-it's `superscript_symbols` config option
|
|
172
|
-
* (index.ts), threaded through so
|
|
173
|
-
* title, typically)
|
|
174
|
-
* inline text.
|
|
274
|
+
* (index.ts), threaded through so ® and © inside the formatted text (a
|
|
275
|
+
* title, typically) render as AsciiDoc superscript rather than plain
|
|
276
|
+
* inline text. ™ and ℠ are unaffected by this flag: `htmlEntryToAsciiDoc`
|
|
277
|
+
* already renders those as AsciiDoc superscript unconditionally, restoring
|
|
278
|
+
* the real character citeproc's own `<sup>TM</sup>`/`<sup>SM</sup>`
|
|
279
|
+
* output would otherwise silently replace with plain "TM"/"SM" text.
|
|
175
280
|
*/
|
|
176
281
|
/** "in preparation" -> "In preparation", matching the style's own
|
|
177
282
|
* `text-case="capitalize-first"` treatment of the same CSL `status`
|