@heroiclands/package-build 25.4.0 → 25.5.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.
@@ -22,6 +22,7 @@ import { parseExtensionAttributes } from "./extension-attributes.mjs";
22
22
  * @property {number} end - Closing line, zero based and inclusive.
23
23
  * @property {number} from - First offset of the complete region.
24
24
  * @property {number} to - Offset past the complete region.
25
+ * @property {number[]} contentStarts - Original-source content offsets for each region line, after container prefixes.
25
26
  * @property {number} bodyStart - First body offset.
26
27
  * @property {number} bodyEnd - Offset past body text, excluding its final newline.
27
28
  * @property {string} body - Authored body bytes.
@@ -81,6 +82,13 @@ export function verseDivPlugin(md) {
81
82
  for (const match of original.matchAll(/\r\n|\r|\n/g))
82
83
  starts.push(match.index + match[0].length);
83
84
  const from = starts[first] ?? original.length;
85
+ const contentStarts = [];
86
+ for (let number = first; number < (closed ? close + 1 : past); number++) {
87
+ const normalizedStart = state.src.lastIndexOf("\n", state.bMarks[number] - 1) + 1;
88
+ contentStarts.push(
89
+ starts[number] + state.bMarks[number] + state.tShift[number] - normalizedStart,
90
+ );
91
+ }
84
92
  const bodyStart = starts[first + 1] ?? original.length;
85
93
  let bodyEnd = starts[close] ?? original.length;
86
94
  if (bodyEnd > bodyStart) {
@@ -91,6 +99,7 @@ export function verseDivPlugin(md) {
91
99
  start: first,
92
100
  end: closed ? close : past - 1,
93
101
  from,
102
+ contentStarts,
94
103
  to: starts[closed ? close + 1 : past] ?? original.length,
95
104
  bodyStart,
96
105
  bodyEnd,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroiclands/package-build",
3
- "version": "25.4.0",
3
+ "version": "25.5.0",
4
4
  "description": "Shared toolchain for building and shipping a HeroicLands Foundry VTT package \u2014 content compilation, manifest, localization, staging, bundle, release and deployment.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",
@@ -2,7 +2,7 @@
2
2
  * Read every `scroll` fence in a source, and every fault in its opening.
3
3
  *
4
4
  * A fence inside a block quote or an HTML block is not read, and neither is a
5
- * fence quoted inside another fence.
5
+ * fence quoted inside another fence. Verse lines are inline content.
6
6
  *
7
7
  * @param {string} source - Markdown.
8
8
  * @returns {{blocks: Scroll[], errors: Array<{line: number, column: number, message: string}>}}
@@ -46,7 +46,7 @@ export function parseVerse(body: string, { inline, footnotes }?: {
46
46
  }): VerseModel;
47
47
  /**
48
48
  * Validate a quoted verse span using its original source coordinates.
49
- * @param {{start: number, text: string, attrs: Array<[string,string]>}} span - Authored span.
49
+ * @param {{start: number, text: string, attrs: Array<[string,string]>, verseModel?: VerseModel}} span - Authored span.
50
50
  * @param {string} source - Complete Markdown source.
51
51
  * @returns {VerseDiagnostic[]} Located inline-only findings.
52
52
  */
@@ -54,6 +54,7 @@ export function inlineVerseFindings(span: {
54
54
  start: number;
55
55
  text: string;
56
56
  attrs: Array<[string, string]>;
57
+ verseModel?: VerseModel;
57
58
  }, source: string): VerseDiagnostic[];
58
59
  /** Logical line text for consumers that do not need source locations. */
59
60
  export function verseLines(body: any): string[];
@@ -214,6 +215,10 @@ export type VerseBlock = {
214
215
  * - Opening div's zero-based source line.
215
216
  */
216
217
  start: number;
218
+ /**
219
+ * - Opening delimiter's one-based source column, when known.
220
+ */
221
+ column?: number | undefined;
217
222
  /**
218
223
  * - Closing div's zero-based source line.
219
224
  */
@@ -273,7 +278,7 @@ export type VerseBlock = {
273
278
  };
274
279
  export type VerseDiagnostic = {
275
280
  line: number;
276
- column: number;
281
+ column?: number;
277
282
  message: string;
278
283
  };
279
284
  /**
@@ -36,9 +36,10 @@
36
36
  * @param {(span: RomanSpan) => string} [options.opaqueSpan] - Placeholder for an independent child. The default empty name keeps sentence state without introducing that child's letters.
37
37
  * @param {ReadonlyArray<readonly [number, number]>} [options.exclude] - Absolute source ranges that carry layout or presentation syntax.
38
38
  * @param {boolean} [options.markNames] - Whether name children contribute braces.
39
+ * @param {boolean} [options.preserveSlashEscape] - Keep a literal verse slash distinct from a line control.
39
40
  * @returns {{text: string, offsets: number[], spans: ProjectedSpan[]}} Logical text and source locations, with child ranges for presentation.
40
41
  */
41
- export function plainRomanRun(source: string, { from, to, spans, includeSpan, opaqueSpan, exclude, markNames, }?: {
42
+ export function plainRomanRun(source: string, { from, to, spans, includeSpan, opaqueSpan, exclude, markNames, preserveSlashEscape, }?: {
42
43
  from?: number | undefined;
43
44
  to?: number | undefined;
44
45
  spans?: readonly RomanSpan[] | undefined;
@@ -46,6 +47,7 @@ export function plainRomanRun(source: string, { from, to, spans, includeSpan, op
46
47
  opaqueSpan?: ((span: RomanSpan) => string) | undefined;
47
48
  exclude?: readonly (readonly [number, number])[] | undefined;
48
49
  markNames?: boolean | undefined;
50
+ preserveSlashEscape?: boolean | undefined;
49
51
  }): {
50
52
  text: string;
51
53
  offsets: number[];
@@ -1,7 +1,8 @@
1
1
  /**
2
- * Replace verse markup with opaque placeholders and restore its original bytes.
2
+ * Replace verse markup with opaque placeholders, retaining container prefixes
3
+ * and inline display widths. Restoration follows the formatter's line endings.
3
4
  * @param {string} source - Complete Markdown source.
4
- * @returns {{markdown: string, restore: (formatted: string) => string}} Protected source and exact restoration.
5
+ * @returns {{markdown: string, restore: (formatted: string) => string}} Protected source and restoration.
5
6
  */
6
7
  export function protectVerseSource(source: string): {
7
8
  markdown: string;
@@ -35,6 +35,10 @@ export type VerseRegion = {
35
35
  * - Offset past the complete region.
36
36
  */
37
37
  to: number;
38
+ /**
39
+ * - Original-source content offsets for each region line, after container prefixes.
40
+ */
41
+ contentStarts: number[];
38
42
  /**
39
43
  * - First body offset.
40
44
  */