asciidoc-abundant-tree 0.1.21 → 0.2.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/README.md +6 -6
- package/dist/animation-yaml-export/cli.d.mts +2 -2
- package/dist/animation-yaml-export/cli.mjs +5 -5
- package/dist/browser.d.mts +1 -1
- package/dist/browser.mjs +62 -146
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/{export-animation-yaml-Tq1LM1lx.d.mts → export-animation-yaml-BHp1vISl.d.mts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-DmtfeBaM.mjs → src-CNTTQlPJ.mjs} +246 -271
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -191,7 +191,7 @@ Default output is a pretty tree:
|
|
|
191
191
|
|
|
192
192
|
```text
|
|
193
193
|
<document mode="single-file" sourcePath="samples/reference-links.adoc">
|
|
194
|
-
<parser name="@asciidoctor/core" version="
|
|
194
|
+
<parser name="@asciidoctor/core" version="4.1.1">
|
|
195
195
|
children[]
|
|
196
196
|
<section idOrigin="source" ids="section-basics" level=1 title="基础概念">
|
|
197
197
|
<source>
|
|
@@ -253,11 +253,11 @@ import {
|
|
|
253
253
|
serializeAbundantTreeToJson,
|
|
254
254
|
} from "asciidoc-abundant-tree";
|
|
255
255
|
|
|
256
|
-
const document = parseAbundantTree({
|
|
256
|
+
const document = await parseAbundantTree({
|
|
257
257
|
sourcePath: "docs/index.adoc",
|
|
258
258
|
});
|
|
259
259
|
|
|
260
|
-
const book = parseAbundantTree({
|
|
260
|
+
const book = await parseAbundantTree({
|
|
261
261
|
sourcePath: "samples/book-entry-demo/book.adoc",
|
|
262
262
|
mode: "book-entry",
|
|
263
263
|
documentRoot: "samples/book-entry-demo",
|
|
@@ -281,7 +281,7 @@ Browser tools that already hold AsciiDoc source text can use the browser-safe su
|
|
|
281
281
|
```ts
|
|
282
282
|
import { parseAbundantTreeFromSource } from "asciidoc-abundant-tree/browser";
|
|
283
283
|
|
|
284
|
-
const document = parseAbundantTreeFromSource({
|
|
284
|
+
const document = await parseAbundantTreeFromSource({
|
|
285
285
|
sourceText,
|
|
286
286
|
sourcePath: "document.adoc",
|
|
287
287
|
});
|
|
@@ -310,7 +310,7 @@ List unresolved local xrefs:
|
|
|
310
310
|
```ts
|
|
311
311
|
import { parseAbundantTree } from "asciidoc-abundant-tree";
|
|
312
312
|
|
|
313
|
-
const document = parseAbundantTree({ sourcePath: "docs/index.adoc" });
|
|
313
|
+
const document = await parseAbundantTree({ sourcePath: "docs/index.adoc" });
|
|
314
314
|
|
|
315
315
|
for (const xref of document.xrefOccurrences) {
|
|
316
316
|
if (xref.scope === "unresolved") {
|
|
@@ -324,7 +324,7 @@ Inspect target kinds:
|
|
|
324
324
|
```ts
|
|
325
325
|
import { parseAbundantTree } from "asciidoc-abundant-tree";
|
|
326
326
|
|
|
327
|
-
const document = parseAbundantTree({ sourcePath: "docs/index.adoc" });
|
|
327
|
+
const document = await parseAbundantTree({ sourcePath: "docs/index.adoc" });
|
|
328
328
|
|
|
329
329
|
const byKind = new Map<string, number>();
|
|
330
330
|
for (const target of document.targets) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as exportAnimationYaml } from "../export-animation-yaml-
|
|
1
|
+
import { r as exportAnimationYaml } from "../export-animation-yaml-BHp1vISl.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/animation-yaml-export/cli.d.ts
|
|
4
4
|
type AnimationYamlCliResult = {
|
|
@@ -6,6 +6,6 @@ type AnimationYamlCliResult = {
|
|
|
6
6
|
readonly stdout: string;
|
|
7
7
|
readonly stderr: string;
|
|
8
8
|
};
|
|
9
|
-
declare function runAnimationYamlCli(args: string[]): AnimationYamlCliResult
|
|
9
|
+
declare function runAnimationYamlCli(args: string[]): Promise<AnimationYamlCliResult>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { AnimationYamlCliResult, exportAnimationYaml, runAnimationYamlCli };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { o as exportAnimationYaml } from "../src-
|
|
2
|
+
import { o as exportAnimationYaml } from "../src-CNTTQlPJ.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
//#region src/animation-yaml-export/cli.ts
|
|
5
5
|
const USAGE = `Usage:
|
|
6
6
|
animation-yaml-export <book.adoc>
|
|
7
7
|
animation-yaml-export <book.adoc> --document-root <root>
|
|
8
8
|
animation-yaml-export --help`;
|
|
9
|
-
function runAnimationYamlCli(args) {
|
|
9
|
+
async function runAnimationYamlCli(args) {
|
|
10
10
|
let parsed;
|
|
11
11
|
try {
|
|
12
12
|
parsed = parseArgs(args);
|
|
@@ -30,10 +30,10 @@ function runAnimationYamlCli(args) {
|
|
|
30
30
|
try {
|
|
31
31
|
return {
|
|
32
32
|
code: 0,
|
|
33
|
-
stdout: exportAnimationYaml({
|
|
33
|
+
stdout: (await exportAnimationYaml({
|
|
34
34
|
sourcePath: parsed.sourcePath,
|
|
35
35
|
...parsed.documentRoot === void 0 ? {} : { documentRoot: parsed.documentRoot }
|
|
36
|
-
}).yaml,
|
|
36
|
+
})).yaml,
|
|
37
37
|
stderr: ""
|
|
38
38
|
};
|
|
39
39
|
} catch (error) {
|
|
@@ -80,7 +80,7 @@ function formatError(error) {
|
|
|
80
80
|
}
|
|
81
81
|
/* c8 ignore start */
|
|
82
82
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
83
|
-
const result = runAnimationYamlCli(process.argv.slice(2));
|
|
83
|
+
const result = await runAnimationYamlCli(process.argv.slice(2));
|
|
84
84
|
if (result.stdout) process.stdout.write(result.stdout);
|
|
85
85
|
if (result.stderr) process.stderr.write(result.stderr.endsWith("\n") ? result.stderr : `${result.stderr}\n`);
|
|
86
86
|
process.exitCode = result.code;
|
package/dist/browser.d.mts
CHANGED
|
@@ -210,7 +210,7 @@ type ParseAbundantTreeFromSourceOptions = {
|
|
|
210
210
|
};
|
|
211
211
|
//#endregion
|
|
212
212
|
//#region src/browser-parser.d.ts
|
|
213
|
-
declare function parseAbundantTreeFromSource(options: ParseAbundantTreeFromSourceOptions): AbundantDocument
|
|
213
|
+
declare function parseAbundantTreeFromSource(options: ParseAbundantTreeFromSourceOptions): Promise<AbundantDocument>;
|
|
214
214
|
//#endregion
|
|
215
215
|
//#region src/serializers.d.ts
|
|
216
216
|
declare function formatAbundantTree(document: AbundantDocument): string;
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Extensions, Inline, getVersion, load } from "@asciidoctor/core";
|
|
2
2
|
import { parseFragment } from "parse5";
|
|
3
3
|
//#region src/macro-argument-parser.ts
|
|
4
4
|
function parseMacroArguments(raw) {
|
|
@@ -71,95 +71,49 @@ function interpretHeadingInlineMetadataAttributes(field, rawAttributes) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
function macroArgumentsFromAttributeRecord(attributes) {
|
|
74
|
-
const positional =
|
|
74
|
+
const positional = [];
|
|
75
75
|
const named = {};
|
|
76
76
|
for (const [key, value] of Object.entries(attributes)) {
|
|
77
|
-
if (
|
|
78
|
-
|
|
77
|
+
if (typeof value !== "string") continue;
|
|
78
|
+
if (/^[1-9]\d*$/u.test(key)) positional[Number(key) - 1] = value.trim();
|
|
79
|
+
else named[key] = value.trim();
|
|
79
80
|
}
|
|
80
81
|
return {
|
|
81
|
-
positional,
|
|
82
|
+
positional: positional.filter((value) => value !== void 0),
|
|
82
83
|
named
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
//#endregion
|
|
86
87
|
//#region src/asciidoctor-adapter.ts
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (!hasRuntimeExtensionFactory(processor)) throw new Error("Asciidoctor runtime does not expose Extensions.create");
|
|
92
|
-
const loadExtensionRegistry = createExtensionRegistry(processor);
|
|
88
|
+
function official(block) {
|
|
89
|
+
return block;
|
|
90
|
+
}
|
|
91
|
+
function createAsciidoctorAdapter(extensionRegistry = createExtensionRegistry()) {
|
|
93
92
|
return {
|
|
94
|
-
parserVersion:
|
|
95
|
-
|
|
96
|
-
return
|
|
93
|
+
parserVersion: getVersion(),
|
|
94
|
+
async loadSource(sourceText) {
|
|
95
|
+
return await load(sourceText, {
|
|
97
96
|
safe: "secure",
|
|
98
97
|
sourcemap: true,
|
|
99
98
|
to_file: false,
|
|
100
|
-
extension_registry:
|
|
99
|
+
extension_registry: extensionRegistry
|
|
101
100
|
});
|
|
102
101
|
},
|
|
103
|
-
loadSource(sourceText) {
|
|
104
|
-
return processor.load(sourceText, {
|
|
105
|
-
safe: "secure",
|
|
106
|
-
sourcemap: true,
|
|
107
|
-
to_file: false,
|
|
108
|
-
extension_registry: loadExtensionRegistry
|
|
109
|
-
});
|
|
110
|
-
},
|
|
111
|
-
readPreprocessedLines(options) {
|
|
112
|
-
const reader = processor.loadFile(options.sourcePath, {
|
|
113
|
-
safe: "unsafe",
|
|
114
|
-
base_dir: options.baseDir,
|
|
115
|
-
...options.jailDir ? { jail_dir: options.jailDir } : {},
|
|
116
|
-
sourcemap: true,
|
|
117
|
-
parse: false,
|
|
118
|
-
to_file: false,
|
|
119
|
-
attributes: options.attributes ?? {},
|
|
120
|
-
extension_registry: loadExtensionRegistry
|
|
121
|
-
}).getReader?.();
|
|
122
|
-
if (!reader) throw new Error("Asciidoctor document does not expose a Reader.");
|
|
123
|
-
const lines = [];
|
|
124
|
-
const pushIds = /* @__PURE__ */ new WeakMap();
|
|
125
|
-
let pushes = 0;
|
|
126
|
-
while (true) {
|
|
127
|
-
const before = readerCursorEvidence(reader.getCursor?.());
|
|
128
|
-
const text = reader.readLine();
|
|
129
|
-
if (text === void 0 || text === null) break;
|
|
130
|
-
const after = readerCursorEvidence(reader.getCursor?.());
|
|
131
|
-
const stack = reader.include_stack ?? [];
|
|
132
|
-
const frame = stack.at(-1);
|
|
133
|
-
if (frame && !pushIds.has(frame)) {
|
|
134
|
-
pushes += 1;
|
|
135
|
-
pushIds.set(frame, pushes);
|
|
136
|
-
}
|
|
137
|
-
lines.push({
|
|
138
|
-
text,
|
|
139
|
-
cursor: cursorForReturnedReaderLine(before, after),
|
|
140
|
-
push: {
|
|
141
|
-
id: frame ? pushIds.get(frame) ?? 0 : 0,
|
|
142
|
-
depth: stack.length
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return lines;
|
|
147
|
-
},
|
|
148
102
|
extractAnchorBindings(html) {
|
|
149
103
|
return extractAnchorBindings(parseFragment(html));
|
|
150
104
|
},
|
|
151
105
|
resolveXrefTarget(document, target) {
|
|
152
106
|
if (target.includes(".adoc#")) return target.replace(".adoc#", ".html#");
|
|
153
|
-
const refs = document.getRefs
|
|
107
|
+
const refs = official(document).getRefs();
|
|
154
108
|
if (Object.hasOwn(refs, target)) return `#${target}`;
|
|
155
|
-
const resolved = document
|
|
156
|
-
return
|
|
109
|
+
const resolved = official(document).resolveId(target);
|
|
110
|
+
return resolved === null ? void 0 : `#${resolved}`;
|
|
157
111
|
},
|
|
158
|
-
resolveXrefBinding(document, parent, xref) {
|
|
112
|
+
async resolveXrefBinding(document, parent, xref) {
|
|
159
113
|
const href = this.resolveXrefTarget(document, xref.target);
|
|
160
114
|
const target = href ?? unresolvedLocalHref(xref.target);
|
|
161
|
-
const reftext = resolveXrefReftext(document, xref, href);
|
|
162
|
-
const anchor = extractAnchorBindings(parseFragment(
|
|
115
|
+
const reftext = await resolveXrefReftext(document, xref, href);
|
|
116
|
+
const anchor = extractAnchorBindings(parseFragment(await new Inline(official(parent), "anchor", reftext, {
|
|
163
117
|
type: "xref",
|
|
164
118
|
target
|
|
165
119
|
}).convert())).find((binding) => binding.href);
|
|
@@ -172,18 +126,9 @@ function createAsciidoctorAdapter() {
|
|
|
172
126
|
}
|
|
173
127
|
};
|
|
174
128
|
}
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
const version = processor.getVersion();
|
|
178
|
-
if (typeof version === "string" && version.length > 0) return version;
|
|
179
|
-
}
|
|
180
|
-
return ASCIIDOCTOR_CORE_VERSION;
|
|
181
|
-
}
|
|
182
|
-
function createExtensionRegistry(processor) {
|
|
183
|
-
const registry = processor.Extensions.create();
|
|
184
|
-
if (!hasProperties(registry) || typeof registry.inlineMacro !== "function") throw new Error("Asciidoctor extension registry cannot register inline macros");
|
|
129
|
+
function createExtensionRegistry() {
|
|
130
|
+
const registry = Extensions.create();
|
|
185
131
|
registry.inlineMacro("hmeta", function() {
|
|
186
|
-
if (!isInlineMacroRegistration(this)) throw new Error("Asciidoctor inline macro registration is unavailable");
|
|
187
132
|
this.positionalAttributes("value");
|
|
188
133
|
this.process((parent, target, attributes) => {
|
|
189
134
|
const interpreted = interpretHeadingInlineMetadataAttributes(target, attributes);
|
|
@@ -192,51 +137,10 @@ function createExtensionRegistry(processor) {
|
|
|
192
137
|
});
|
|
193
138
|
return registry;
|
|
194
139
|
}
|
|
195
|
-
function
|
|
196
|
-
if (!hasProperties(cursor)) return {};
|
|
197
|
-
return definedReaderCursor({
|
|
198
|
-
file: typeof cursor.getFile === "function" ? cursor.getFile() : void 0,
|
|
199
|
-
directory: typeof cursor.getDirectory === "function" ? cursor.getDirectory() : void 0,
|
|
200
|
-
path: typeof cursor.getPath === "function" ? cursor.getPath() : void 0,
|
|
201
|
-
lineNumber: typeof cursor.getLineNumber === "function" ? cursor.getLineNumber() : void 0
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
function definedReaderCursor(cursor) {
|
|
205
|
-
return {
|
|
206
|
-
...typeof cursor.file === "string" ? { file: cursor.file } : {},
|
|
207
|
-
...typeof cursor.directory === "string" ? { directory: cursor.directory } : {},
|
|
208
|
-
...typeof cursor.path === "string" ? { path: cursor.path } : {},
|
|
209
|
-
...typeof cursor.lineNumber === "number" ? { lineNumber: cursor.lineNumber } : {}
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function cursorForReturnedReaderLine(before, after) {
|
|
213
|
-
if (before.file === after.file && before.lineNumber !== void 0 && after.lineNumber === before.lineNumber + 1) return before;
|
|
214
|
-
if (after.lineNumber !== void 0 && after.lineNumber > 1) return definedReaderCursor({
|
|
215
|
-
...after,
|
|
216
|
-
lineNumber: after.lineNumber - 1
|
|
217
|
-
});
|
|
218
|
-
return before;
|
|
219
|
-
}
|
|
220
|
-
function hasRuntimeInlineFactory(value) {
|
|
221
|
-
if (!hasProperties(value) || !hasProperties(value.Inline)) return false;
|
|
222
|
-
return typeof value.Inline.create === "function";
|
|
223
|
-
}
|
|
224
|
-
function hasRuntimeExtensionFactory(value) {
|
|
225
|
-
if (!hasProperties(value) || !hasProperties(value.Extensions)) return false;
|
|
226
|
-
return typeof value.Extensions.create === "function";
|
|
227
|
-
}
|
|
228
|
-
function isInlineMacroRegistration(value) {
|
|
229
|
-
return hasProperties(value) && typeof value.positionalAttributes === "function" && typeof value.process === "function" && typeof value.createInline === "function";
|
|
230
|
-
}
|
|
231
|
-
function resolveXrefReftext(document, xref, href) {
|
|
140
|
+
async function resolveXrefReftext(document, xref, href) {
|
|
232
141
|
if (xref.label) return xref.label;
|
|
233
142
|
const resolvedId = href?.startsWith("#") ? href.slice(1) : void 0;
|
|
234
|
-
|
|
235
|
-
if (isAsciidoctorRef(ref)) {
|
|
236
|
-
const xreftext = ref.$xreftext();
|
|
237
|
-
if (typeof xreftext === "string") return xreftext;
|
|
238
|
-
}
|
|
239
|
-
return `[${xref.target}]`;
|
|
143
|
+
return await (resolvedId ? official(document).getRefs()[resolvedId] : void 0)?.xreftext() ?? `[${xref.target}]`;
|
|
240
144
|
}
|
|
241
145
|
function unresolvedLocalHref(target) {
|
|
242
146
|
if (target.includes(".adoc#")) return target.replace(".adoc#", ".html#");
|
|
@@ -245,15 +149,6 @@ function unresolvedLocalHref(target) {
|
|
|
245
149
|
function resolvedIdFromHref(href) {
|
|
246
150
|
return href.startsWith("#") ? href.slice(1) : href.split("#").at(1);
|
|
247
151
|
}
|
|
248
|
-
function isAsciidoctorRef(value) {
|
|
249
|
-
return isRecord$2(value) && typeof value.$xreftext === "function";
|
|
250
|
-
}
|
|
251
|
-
function isRecord$2(value) {
|
|
252
|
-
return value !== null && typeof value === "object";
|
|
253
|
-
}
|
|
254
|
-
function hasProperties(value) {
|
|
255
|
-
return value !== null && (typeof value === "object" || typeof value === "function");
|
|
256
|
-
}
|
|
257
152
|
function extractAnchorBindings(fragment) {
|
|
258
153
|
const bindings = [];
|
|
259
154
|
function walk(node) {
|
|
@@ -284,10 +179,17 @@ function isElement(node) {
|
|
|
284
179
|
//#endregion
|
|
285
180
|
//#region src/object-utils.ts
|
|
286
181
|
function definedObject(object) {
|
|
287
|
-
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== void 0));
|
|
182
|
+
return Object.fromEntries(Object.entries(object).filter(([, value]) => value !== void 0 && value !== null));
|
|
288
183
|
}
|
|
289
184
|
//#endregion
|
|
290
185
|
//#region src/binding-merge.ts
|
|
186
|
+
async function resolveOfficialBindings(requests, officialDocument, adapter) {
|
|
187
|
+
for (const { block, xrefs } of requests) {
|
|
188
|
+
const bindings = [];
|
|
189
|
+
for (const xref of xrefs) bindings.push(await adapter.resolveXrefBinding(officialDocument, block, xref));
|
|
190
|
+
applyOfficialBindings(xrefs, bindings);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
291
193
|
function addTarget(targets, target) {
|
|
292
194
|
if (!target.id || targets.some((existing) => existing.id === target.id)) return;
|
|
293
195
|
targets.push(target);
|
|
@@ -1098,6 +1000,7 @@ function descriptionListItemFromRaw(rawItem) {
|
|
|
1098
1000
|
//#region src/official-projector.ts
|
|
1099
1001
|
function projectOfficialDocument(options) {
|
|
1100
1002
|
const targets = [];
|
|
1003
|
+
const bindingRequests = [];
|
|
1101
1004
|
const sourceAwareDocument = sourceAwareDocumentForLineTable(options.lineTable);
|
|
1102
1005
|
const logicalSource = logicalSourceForLineTable(options.lineTable);
|
|
1103
1006
|
const context = definedObject({
|
|
@@ -1116,14 +1019,15 @@ function projectOfficialDocument(options) {
|
|
|
1116
1019
|
projectableBlocks: options.projectableBlocks,
|
|
1117
1020
|
containerFallbackBlocks: options.containerFallbackBlocks,
|
|
1118
1021
|
sectionByBlock: options.sectionByBlock,
|
|
1119
|
-
|
|
1022
|
+
bindingRequests,
|
|
1120
1023
|
targets,
|
|
1121
1024
|
sourceAwareDocument,
|
|
1122
1025
|
...logicalSource ? { logicalSource } : {}
|
|
1123
1026
|
});
|
|
1124
1027
|
return {
|
|
1125
1028
|
children: buildChildren(options.officialDocument, context),
|
|
1126
|
-
targets
|
|
1029
|
+
targets,
|
|
1030
|
+
bindingRequests
|
|
1127
1031
|
};
|
|
1128
1032
|
}
|
|
1129
1033
|
function buildChildren(officialDocument, context) {
|
|
@@ -1259,7 +1163,10 @@ function buildDescriptionTerm(block, context) {
|
|
|
1259
1163
|
return true;
|
|
1260
1164
|
}) : [];
|
|
1261
1165
|
const headingInlineMetadata = span ? collectHeadingInlineMetadataInSpan(context, span, source).filter((occurrence) => isOccurrenceInsideSourceSpan(occurrence, sourceSpan)) : [];
|
|
1262
|
-
|
|
1166
|
+
context.bindingRequests.push({
|
|
1167
|
+
block,
|
|
1168
|
+
xrefs
|
|
1169
|
+
});
|
|
1263
1170
|
return definedObject({
|
|
1264
1171
|
kind: "descriptionTerm",
|
|
1265
1172
|
text: normalizedListItemText(block),
|
|
@@ -1292,7 +1199,10 @@ function buildDescription(block, context) {
|
|
|
1292
1199
|
return true;
|
|
1293
1200
|
}) : [];
|
|
1294
1201
|
const headingInlineMetadata = span ? collectHeadingInlineMetadataInSpan(context, span, source).filter((occurrence) => isOccurrenceInsideSourceSpan(occurrence, sourceSpan)) : [];
|
|
1295
|
-
|
|
1202
|
+
context.bindingRequests.push({
|
|
1203
|
+
block,
|
|
1204
|
+
xrefs
|
|
1205
|
+
});
|
|
1296
1206
|
const children = [
|
|
1297
1207
|
...xrefs,
|
|
1298
1208
|
...anchors,
|
|
@@ -1445,7 +1355,10 @@ function buildParagraph(block, line, context, interval) {
|
|
|
1445
1355
|
return true;
|
|
1446
1356
|
});
|
|
1447
1357
|
const headingInlineMetadata = collectHeadingInlineMetadataInSpan(context, contentSpan, source);
|
|
1448
|
-
|
|
1358
|
+
context.bindingRequests.push({
|
|
1359
|
+
block,
|
|
1360
|
+
xrefs
|
|
1361
|
+
});
|
|
1449
1362
|
const sourceSpan = source?.sourceSpan;
|
|
1450
1363
|
const asciidoctor = definedObject({
|
|
1451
1364
|
context: block.getContext?.(),
|
|
@@ -1467,7 +1380,7 @@ function buildParagraph(block, line, context, interval) {
|
|
|
1467
1380
|
};
|
|
1468
1381
|
registerOfficialBlockTarget(context, block, {
|
|
1469
1382
|
targetType: "block",
|
|
1470
|
-
title: block.getTitle?.(),
|
|
1383
|
+
title: block.getTitle?.() ?? void 0,
|
|
1471
1384
|
sourceSpan,
|
|
1472
1385
|
source,
|
|
1473
1386
|
asciidoctor
|
|
@@ -1541,13 +1454,16 @@ function buildTable(block, delimiterLine, context, interval) {
|
|
|
1541
1454
|
return true;
|
|
1542
1455
|
});
|
|
1543
1456
|
const tableHeadingInlineMetadata = collectHeadingInlineMetadataInSpan(context, tableContentSpan, source);
|
|
1544
|
-
|
|
1457
|
+
context.bindingRequests.push({
|
|
1458
|
+
block,
|
|
1459
|
+
xrefs: tableXrefs
|
|
1460
|
+
});
|
|
1545
1461
|
const table = definedObject({
|
|
1546
1462
|
kind: "table",
|
|
1547
1463
|
ids,
|
|
1548
1464
|
title: metadata.find((surface) => surface.title)?.title ?? block.getTitle?.(),
|
|
1549
1465
|
metadata: metadata.map((surface) => surface.node),
|
|
1550
|
-
rows: rowsFromTable(block.
|
|
1466
|
+
rows: rowsFromTable(block.rows),
|
|
1551
1467
|
span: source?.span,
|
|
1552
1468
|
source,
|
|
1553
1469
|
asciidoctor: definedObject({
|
|
@@ -1917,7 +1833,7 @@ function scanTableInlineRange(lineTable, block, _startLine, _endLine, xrefOccurr
|
|
|
1917
1833
|
for (const range of mergeLineSpans(collectTableScannableRanges(block))) scanInlineRange(lineTable, range.startLine, range.endLine, xrefOccurrences, anchorOccurrences, headingInlineMetadataOccurrences, toolDiagnostics);
|
|
1918
1834
|
}
|
|
1919
1835
|
function collectTableScannableRanges(block) {
|
|
1920
|
-
const rows = block.
|
|
1836
|
+
const rows = block.rows;
|
|
1921
1837
|
if (!isRecord(rows)) return [];
|
|
1922
1838
|
const ranges = [];
|
|
1923
1839
|
for (const groupName of [
|
|
@@ -1954,7 +1870,7 @@ function innerBlocksFromCell(cell) {
|
|
|
1954
1870
|
function ordinaryCellRange(cell) {
|
|
1955
1871
|
const startLine = cell.getLineNumber?.();
|
|
1956
1872
|
if (startLine === void 0) return [];
|
|
1957
|
-
const lines = cell.
|
|
1873
|
+
const lines = cell.lines;
|
|
1958
1874
|
return [{
|
|
1959
1875
|
startLine,
|
|
1960
1876
|
endLine: startLine + (Array.isArray(lines) ? Math.max(1, lines.length) : 1) - 1
|
|
@@ -2122,7 +2038,7 @@ function walkBlock(block, parent, indexInParent) {
|
|
|
2122
2038
|
context: block.getContext?.(),
|
|
2123
2039
|
nodeName: block.getNodeName?.(),
|
|
2124
2040
|
level: block.getLevel?.(),
|
|
2125
|
-
title: block.getTitle?.(),
|
|
2041
|
+
title: block.getTitle?.() ?? void 0,
|
|
2126
2042
|
id: block.getId?.(),
|
|
2127
2043
|
sourceLine: sourceLocation?.getLineNumber?.(),
|
|
2128
2044
|
sourceFile: sourceLocation?.getFile?.(),
|
|
@@ -2677,7 +2593,7 @@ function mapSectionScope(sections, totalLines) {
|
|
|
2677
2593
|
}
|
|
2678
2594
|
//#endregion
|
|
2679
2595
|
//#region src/parser-core.ts
|
|
2680
|
-
function parseAsciidoctorDocument(input) {
|
|
2596
|
+
async function parseAsciidoctorDocument(input) {
|
|
2681
2597
|
const sourceSurfaces = projectSourceSurfaces({
|
|
2682
2598
|
officialDocument: input.officialDocument,
|
|
2683
2599
|
lineTable: input.lineTable,
|
|
@@ -2695,9 +2611,9 @@ function parseAsciidoctorDocument(input) {
|
|
|
2695
2611
|
intervalByBlock: sourceSurfaces.intervalByBlock,
|
|
2696
2612
|
projectableBlocks: sourceSurfaces.projectableBlocks,
|
|
2697
2613
|
containerFallbackBlocks: sourceSurfaces.containerFallbackBlocks,
|
|
2698
|
-
sectionByBlock: sourceSurfaces.sectionByBlock
|
|
2699
|
-
adapter: input.adapter
|
|
2614
|
+
sectionByBlock: sourceSurfaces.sectionByBlock
|
|
2700
2615
|
});
|
|
2616
|
+
await resolveOfficialBindings(officialProjection.bindingRequests, input.officialDocument, input.adapter);
|
|
2701
2617
|
addAnchorTargets(officialProjection.targets, sourceSurfaces.anchorOccurrences);
|
|
2702
2618
|
bindXrefs(sourceSurfaces.xrefOccurrences, officialProjection.targets);
|
|
2703
2619
|
const titleSource = documentTitleSource(input.lineTable);
|
|
@@ -2795,11 +2711,11 @@ function sourceIdentityPrefix(path) {
|
|
|
2795
2711
|
//#endregion
|
|
2796
2712
|
//#region src/browser-parser.ts
|
|
2797
2713
|
const DEFAULT_BROWSER_SOURCE_PATH = "document.adoc";
|
|
2798
|
-
function parseAbundantTreeFromSource(options) {
|
|
2714
|
+
async function parseAbundantTreeFromSource(options) {
|
|
2799
2715
|
const sourcePath = options.sourcePath ?? DEFAULT_BROWSER_SOURCE_PATH;
|
|
2800
2716
|
const adapter = createAsciidoctorAdapter();
|
|
2801
2717
|
return parseAsciidoctorDocument({
|
|
2802
|
-
officialDocument: adapter.loadSource(options.sourceText),
|
|
2718
|
+
officialDocument: await adapter.loadSource(options.sourceText),
|
|
2803
2719
|
adapter,
|
|
2804
2720
|
lineTable: buildLineTable(options.sourceText),
|
|
2805
2721
|
sourcePath,
|
package/dist/cli.d.mts
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as parseAbundantTree, i as serializeAbundantTreeToJson, n as formatAbundantTree, t as rdf12 } from "./src-
|
|
2
|
+
import { a as parseAbundantTree, i as serializeAbundantTreeToJson, n as formatAbundantTree, t as rdf12 } from "./src-CNTTQlPJ.mjs";
|
|
3
3
|
import { relative, resolve, sep } from "node:path";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import process from "node:process";
|
|
@@ -12,7 +12,7 @@ const USAGE = `Usage:
|
|
|
12
12
|
asciidoc-abundant-tree --help
|
|
13
13
|
|
|
14
14
|
Default mode is single-file. In book-entry mode, --document-root is the relativePath basis and path boundary; when omitted it defaults to the current working directory. JSON is a machine-friendly projection of the same TypeScript document model. ADOC output writes the parser input source; in book-entry mode that source is the include-expanded logical document. RDF 1.2 output is available as Turtle text or JSON-LD.`;
|
|
15
|
-
function runCli(args) {
|
|
15
|
+
async function runCli(args) {
|
|
16
16
|
let parsed;
|
|
17
17
|
try {
|
|
18
18
|
parsed = parseArgs(args);
|
|
@@ -51,7 +51,7 @@ function runCli(args) {
|
|
|
51
51
|
stdout: "",
|
|
52
52
|
stderr: `Input source path is outside document root: ${inputPath}`
|
|
53
53
|
};
|
|
54
|
-
const document = parseAbundantTree(parserOptions(parsed, inputPath, documentRoot));
|
|
54
|
+
const document = await parseAbundantTree(parserOptions(parsed, inputPath, documentRoot));
|
|
55
55
|
if (parsed.format === "rdf12") return {
|
|
56
56
|
code: 0,
|
|
57
57
|
stdout: rdf12(document, { documentRoot }).ttl,
|
|
@@ -162,7 +162,7 @@ function formatError(error) {
|
|
|
162
162
|
}
|
|
163
163
|
/* c8 ignore start */
|
|
164
164
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
165
|
-
const result = runCli(process.argv.slice(2));
|
|
165
|
+
const result = await runCli(process.argv.slice(2));
|
|
166
166
|
if (result.stdout) process.stdout.write(result.stdout.endsWith("\n") ? result.stdout : `${result.stdout}\n`);
|
|
167
167
|
if (result.stderr) process.stderr.write(result.stderr.endsWith("\n") ? result.stderr : `${result.stderr}\n`);
|
|
168
168
|
process.exitCode = result.code;
|
|
@@ -14,6 +14,6 @@ type ExportAnimationYamlResult = {
|
|
|
14
14
|
readonly yaml: string;
|
|
15
15
|
readonly warnings: readonly ExportWarning[];
|
|
16
16
|
};
|
|
17
|
-
declare function exportAnimationYaml(options: ExportAnimationYamlOptions): ExportAnimationYamlResult
|
|
17
|
+
declare function exportAnimationYaml(options: ExportAnimationYamlOptions): Promise<ExportAnimationYamlResult>;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { ExportAnimationYamlResult as n, exportAnimationYaml as r, ExportAnimationYamlOptions as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ExportAnimationYamlResult, r as exportAnimationYaml, t as ExportAnimationYamlOptions } from "./export-animation-yaml-
|
|
1
|
+
import { n as ExportAnimationYamlResult, r as exportAnimationYaml, t as ExportAnimationYamlOptions } from "./export-animation-yaml-BHp1vISl.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/model.d.ts
|
|
4
4
|
type OutputFormat = "tree" | "json";
|
|
@@ -340,7 +340,7 @@ type Rdf12Projection = {
|
|
|
340
340
|
};
|
|
341
341
|
//#endregion
|
|
342
342
|
//#region src/parser.d.ts
|
|
343
|
-
declare function parseAbundantTree(options: ParseAbundantTreeOptions): AbundantDocument
|
|
343
|
+
declare function parseAbundantTree(options: ParseAbundantTreeOptions): Promise<AbundantDocument>;
|
|
344
344
|
//#endregion
|
|
345
345
|
//#region src/serializers.d.ts
|
|
346
346
|
declare function formatAbundantTree(document: AbundantDocument): string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as parseAbundantTree, i as serializeAbundantTreeToJson, n as formatAbundantTree, o as exportAnimationYaml, r as serializeAbundantTree, t as rdf12 } from "./src-
|
|
1
|
+
import { a as parseAbundantTree, i as serializeAbundantTreeToJson, n as formatAbundantTree, o as exportAnimationYaml, r as serializeAbundantTree, t as rdf12 } from "./src-CNTTQlPJ.mjs";
|
|
2
2
|
export { exportAnimationYaml, formatAbundantTree, parseAbundantTree, rdf12, serializeAbundantTree, serializeAbundantTreeToJson };
|