asciidoc-abundant-tree 0.2.5 → 0.2.6

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { o as exportAnimationYaml } from "../src-DdGRLADG.mjs";
2
+ import { o as exportAnimationYaml } from "../src-COUYWnMz.mjs";
3
3
  import process from "node:process";
4
4
  //#region src/animation-yaml-export/cli.ts
5
5
  const USAGE = `Usage:
package/dist/browser.mjs CHANGED
@@ -1155,6 +1155,7 @@ function buildNode(block, context) {
1155
1155
  })
1156
1156
  });
1157
1157
  requestTitleBindings(context, block);
1158
+ requestListItemBindings(context, block);
1158
1159
  return childBlocksOf(block).flatMap((child) => toNodes(buildNode(child, context)));
1159
1160
  }
1160
1161
  }
@@ -1171,6 +1172,15 @@ function requestTitleBindings(context, block) {
1171
1172
  xrefs
1172
1173
  });
1173
1174
  }
1175
+ function requestListItemBindings(context, block) {
1176
+ if (block.getContext?.() !== "list_item") return;
1177
+ const span = context.intervalByBlock.get(block)?.contentSpan;
1178
+ const xrefs = span ? collectXrefsInSpan(context, span) : [];
1179
+ if (xrefs.length > 0) context.bindingRequests.push({
1180
+ block,
1181
+ xrefs
1182
+ });
1183
+ }
1174
1184
  function canProjectBlock(block, context) {
1175
1185
  return context.projectableBlocks?.has(block) ?? true;
1176
1186
  }
@@ -1947,7 +1957,7 @@ function resolveSourceInterval(surface, sourceTable) {
1947
1957
  const undelimited = delimitedContext && delimited === void 0 && !synthesized ? resolveUndelimitedBlockSpan(lineTable, sourceTable, blockStartLine, surface) : void 0;
1948
1958
  const sourceContentSpan = sourceContentSpanForContext(surface, lineTable, blockStartLine);
1949
1959
  const nextSiblingStart = nextSiblingStartLine(surface, lineTable);
1950
- const childEndLine = surface.context === "dlist" ? lastChildEndLine(surface, lineTable) : void 0;
1960
+ const childEndLine = surface.context === "dlist" ? lastChildEndLine(surface, sourceTable) : void 0;
1951
1961
  const endLine = delimited?.span.endLine ?? undelimited?.span.endLine ?? sourceContentSpan?.endLine ?? childEndLine ?? (nextSiblingStart !== void 0 ? nextSiblingStart - 1 : void 0) ?? parentEndLine(surface, sourceTable) ?? lineTable.lines.length;
1952
1962
  const span = normalizeLineSpan({
1953
1963
  startLine,
@@ -2015,18 +2025,24 @@ function metadataForSurface(surface, lineTable, blockStartLine) {
2015
2025
  if (takesParentSourceLocation(surface.block)) return [];
2016
2026
  return collectPrecedingMetadata(lineTable, blockStartLine);
2017
2027
  }
2018
- function lastChildEndLine(surface, lineTable) {
2019
- const childLines = surface.children.flatMap((child) => descendantSourceLines(child, lineTable));
2028
+ function lastChildEndLine(surface, sourceTable) {
2029
+ const childLines = surface.children.map((child) => enclosedEndLine(child, sourceTable)).filter((line) => line !== void 0);
2020
2030
  if (childLines.length === 0) return;
2021
- return Math.min(Math.max(...childLines), lastContentLine(lineTable));
2031
+ return Math.min(Math.max(...childLines), lastContentLine(sourceTable));
2022
2032
  }
2023
- function descendantSourceLines(surface, lineTable) {
2024
- const textEnd = isDescription(surface) ? descriptionTextOf(surface, lineTable)?.span.endLine : void 0;
2025
- return [
2026
- ...surface.sourceLine === void 0 ? [] : [surface.sourceLine],
2027
- ...textEnd === void 0 ? [] : [textEnd],
2028
- ...surface.children.flatMap((child) => descendantSourceLines(child, lineTable))
2029
- ];
2033
+ function enclosedEndLine(surface, sourceTable) {
2034
+ const ends = [surface.sourceLine === void 0 ? void 0 : ownEndLine(surface, sourceTable, surface.sourceLine), ...surface.children.map((child) => enclosedEndLine(child, sourceTable))].filter((line) => line !== void 0);
2035
+ return ends.length > 0 ? Math.max(...ends) : void 0;
2036
+ }
2037
+ function ownEndLine(surface, sourceTable, startLine) {
2038
+ const lineTable = quotedLineTable(sourceTable, markdownQuoteDepth(surface.block));
2039
+ const delimited = isDelimitedContext(surface.context) && !borrowsChildSourceLocation(surface.block) ? resolveDelimitedBlockSpan(lineTable, startLine, surface) ?? resolveUndelimitedBlockSpan(lineTable, sourceTable, startLine, surface) : void 0;
2040
+ if (delimited) return delimited.span.endLine;
2041
+ const paragraph = sourceContentSpanForContext(surface, lineTable, startLine);
2042
+ if (paragraph) return paragraph.endLine;
2043
+ if (isDescription(surface)) return descriptionTextOf(surface, lineTable)?.span.endLine ?? startLine;
2044
+ if (surface.context === "list_item" && surface.parent?.context !== "dlist") return listItemTextEndLine(lineTable, startLine);
2045
+ return startLine;
2030
2046
  }
2031
2047
  function parentEndLine(surface, lineTable) {
2032
2048
  const parent = surface.parent;
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-DdGRLADG.mjs";
2
+ import { a as parseAbundantTree, i as serializeAbundantTreeToJson, n as formatAbundantTree, t as rdf12 } from "./src-COUYWnMz.mjs";
3
3
  import { relative, resolve, sep } from "node:path";
4
4
  import { existsSync } from "node:fs";
5
5
  import process from "node:process";
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-DdGRLADG.mjs";
1
+ import { a as parseAbundantTree, i as serializeAbundantTreeToJson, n as formatAbundantTree, o as exportAnimationYaml, r as serializeAbundantTree, t as rdf12 } from "./src-COUYWnMz.mjs";
2
2
  export { exportAnimationYaml, formatAbundantTree, parseAbundantTree, rdf12, serializeAbundantTree, serializeAbundantTreeToJson };
@@ -4157,6 +4157,7 @@ function buildNode(block, context) {
4157
4157
  })
4158
4158
  });
4159
4159
  requestTitleBindings(context, block);
4160
+ requestListItemBindings(context, block);
4160
4161
  return childBlocksOf(block).flatMap((child) => toNodes(buildNode(child, context)));
4161
4162
  }
4162
4163
  }
@@ -4173,6 +4174,15 @@ function requestTitleBindings(context, block) {
4173
4174
  xrefs
4174
4175
  });
4175
4176
  }
4177
+ function requestListItemBindings(context, block) {
4178
+ if (block.getContext?.() !== "list_item") return;
4179
+ const span = context.intervalByBlock.get(block)?.contentSpan;
4180
+ const xrefs = span ? collectXrefsInSpan(context, span) : [];
4181
+ if (xrefs.length > 0) context.bindingRequests.push({
4182
+ block,
4183
+ xrefs
4184
+ });
4185
+ }
4176
4186
  function canProjectBlock(block, context) {
4177
4187
  return context.projectableBlocks?.has(block) ?? true;
4178
4188
  }
@@ -4949,7 +4959,7 @@ function resolveSourceInterval(surface, sourceTable) {
4949
4959
  const undelimited = delimitedContext && delimited === void 0 && !synthesized ? resolveUndelimitedBlockSpan(lineTable, sourceTable, blockStartLine, surface) : void 0;
4950
4960
  const sourceContentSpan = sourceContentSpanForContext(surface, lineTable, blockStartLine);
4951
4961
  const nextSiblingStart = nextSiblingStartLine(surface, lineTable);
4952
- const childEndLine = surface.context === "dlist" ? lastChildEndLine(surface, lineTable) : void 0;
4962
+ const childEndLine = surface.context === "dlist" ? lastChildEndLine(surface, sourceTable) : void 0;
4953
4963
  const endLine = delimited?.span.endLine ?? undelimited?.span.endLine ?? sourceContentSpan?.endLine ?? childEndLine ?? (nextSiblingStart !== void 0 ? nextSiblingStart - 1 : void 0) ?? parentEndLine(surface, sourceTable) ?? lineTable.lines.length;
4954
4964
  const span = normalizeLineSpan({
4955
4965
  startLine,
@@ -5017,18 +5027,24 @@ function metadataForSurface(surface, lineTable, blockStartLine) {
5017
5027
  if (takesParentSourceLocation(surface.block)) return [];
5018
5028
  return collectPrecedingMetadata(lineTable, blockStartLine);
5019
5029
  }
5020
- function lastChildEndLine(surface, lineTable) {
5021
- const childLines = surface.children.flatMap((child) => descendantSourceLines(child, lineTable));
5030
+ function lastChildEndLine(surface, sourceTable) {
5031
+ const childLines = surface.children.map((child) => enclosedEndLine(child, sourceTable)).filter((line) => line !== void 0);
5022
5032
  if (childLines.length === 0) return;
5023
- return Math.min(Math.max(...childLines), lastContentLine(lineTable));
5033
+ return Math.min(Math.max(...childLines), lastContentLine(sourceTable));
5024
5034
  }
5025
- function descendantSourceLines(surface, lineTable) {
5026
- const textEnd = isDescription(surface) ? descriptionTextOf(surface, lineTable)?.span.endLine : void 0;
5027
- return [
5028
- ...surface.sourceLine === void 0 ? [] : [surface.sourceLine],
5029
- ...textEnd === void 0 ? [] : [textEnd],
5030
- ...surface.children.flatMap((child) => descendantSourceLines(child, lineTable))
5031
- ];
5035
+ function enclosedEndLine(surface, sourceTable) {
5036
+ const ends = [surface.sourceLine === void 0 ? void 0 : ownEndLine(surface, sourceTable, surface.sourceLine), ...surface.children.map((child) => enclosedEndLine(child, sourceTable))].filter((line) => line !== void 0);
5037
+ return ends.length > 0 ? Math.max(...ends) : void 0;
5038
+ }
5039
+ function ownEndLine(surface, sourceTable, startLine) {
5040
+ const lineTable = quotedLineTable(sourceTable, markdownQuoteDepth(surface.block));
5041
+ const delimited = isDelimitedContext(surface.context) && !borrowsChildSourceLocation(surface.block) ? resolveDelimitedBlockSpan(lineTable, startLine, surface) ?? resolveUndelimitedBlockSpan(lineTable, sourceTable, startLine, surface) : void 0;
5042
+ if (delimited) return delimited.span.endLine;
5043
+ const paragraph = sourceContentSpanForContext(surface, lineTable, startLine);
5044
+ if (paragraph) return paragraph.endLine;
5045
+ if (isDescription(surface)) return descriptionTextOf(surface, lineTable)?.span.endLine ?? startLine;
5046
+ if (surface.context === "list_item" && surface.parent?.context !== "dlist") return listItemTextEndLine(lineTable, startLine);
5047
+ return startLine;
5032
5048
  }
5033
5049
  function parentEndLine(surface, lineTable) {
5034
5050
  const parent = surface.parent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asciidoc-abundant-tree",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Recover a source-aware, analysis-ready tree from AsciiDoc files and explicit book-entry include graphs.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {