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 +23 -0
- package/dist/animation-yaml-export/cli.mjs +1 -1
- package/dist/browser.d.mts +2 -1
- package/dist/browser.mjs +298 -188
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +20 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-CNTTQlPJ.mjs → src-DmT-MEPN.mjs} +471 -267
- package/package.json +1 -1
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:
|
package/dist/browser.d.mts
CHANGED
|
@@ -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";
|