asciidoc-abundant-tree 0.2.0 → 0.2.2

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/README.md CHANGED
@@ -274,6 +274,29 @@ const ttl = projection.ttl;
274
274
  const jsonLd = projection.jsonLd;
275
275
  ```
276
276
 
277
+ Book-entry callers can register include resolvers for includes that select by something other than a file path, such as a symbol in a TypeScript file. A resolver claims targets by prefix and returns whole consecutive lines of a source file inside `documentRoot`, plus the line they start at; the lines get coordinates in that file just like a file include:
278
+
279
+ ```ts
280
+ const book = await parseAbundantTree({
281
+ sourcePath: "bookshelf/books/08-design/book.adoc",
282
+ mode: "book-entry",
283
+ documentRoot: ".",
284
+ includeResolvers: [
285
+ {
286
+ // include::docloom:examples/replay.ts[symbol=replay,part=source]
287
+ prefix: "docloom:",
288
+ resolve: ({ target, attributes }) => {
289
+ // Your own selector: find the declaration, widen it to whole lines.
290
+ const { text, startLine } = selectWholeLines(target, attributes);
291
+ return { text, origin: { path: target, startLine } };
292
+ },
293
+ },
294
+ ],
295
+ });
296
+ ```
297
+
298
+ `attributes` are the include attributes as Asciidoctor parses them, the same an Asciidoctor include processor receives, so the bookshelf build and this parser can register the same selector. A blank positional attribute is `null`: the first one in `[,beta]`, the second one in `[beta,,gamma]`. A resolver that throws fails construction with `include.resolver-failed`; returned text that does not match its source leaves those lines without coordinates and reports `origin-map.selection-mismatch`.
299
+
277
300
  `parseAbundantTree` reads only the supplied source file. Interdocument xrefs keep their raw target and official href when Asciidoctor exposes one, but this package does not open the referenced `.adoc` file.
278
301
 
279
302
  Browser tools that already hold AsciiDoc source text can use the browser-safe subpath:
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { o as exportAnimationYaml } from "../src-CNTTQlPJ.mjs";
2
+ import { o as exportAnimationYaml } from "../src-DmT-MEPN.mjs";
3
3
  import process from "node:process";
4
4
  //#region src/animation-yaml-export/cli.ts
5
5
  const USAGE = `Usage:
@@ -154,7 +154,7 @@ type XrefOccurrenceNode = NodeBase & {
154
154
  };
155
155
  type AnchorOccurrenceNode = NodeBase & {
156
156
  kind: "anchor";
157
- syntax: "double-bracket" | "macro";
157
+ syntax: "double-bracket" | "macro" | "bibliography";
158
158
  raw: string;
159
159
  ids: string[];
160
160
  reftext?: string;
@@ -179,6 +179,7 @@ type TargetNode = NodeBase & {
179
179
  title?: string;
180
180
  idOrigin: "source" | "asciidoctor-generated" | "unknown";
181
181
  sourceSpan?: SourceSpan;
182
+ containingSectionId?: string;
182
183
  };
183
184
  type TextNode = NodeBase & {
184
185
  kind: "text";