rapier-markdown-kit 1.1.31 → 1.1.32

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.
@@ -129,6 +129,29 @@ export function parseAssets(source, factory = configured || globalThis.markdowni
129
129
  }
130
130
  export function documentAssets(source, factory) { return parseAssets(source, factory, markdownBodyOffset(source)); }
131
131
 
132
+ // Project only parser-recognized payload spans. Their ordinary data URL remains a data URL,
133
+ // with every source newline intact; the parser never needs megabytes of picture bytes.
134
+ export function projectImageDefinitions(source, index) {
135
+ const records = [], parts = [];
136
+ let at = 0, length = 0;
137
+ for (const row of index.blocks) {
138
+ if (!Number.isSafeInteger(row.payloadStart) || !Number.isSafeInteger(row.payloadEnd) || row.payloadStart < at) continue;
139
+ const text = source.slice(at, row.payloadStart);
140
+ parts.push(text, 'AA=='); length += text.length;
141
+ records.push({start: length, end: length + 4, id: row.id, codec: row.codec,
142
+ payload: source.slice(row.payloadStart, row.payloadEnd), url: row.url});
143
+ length += 4; at = row.payloadEnd;
144
+ }
145
+ parts.push(source.slice(at));
146
+ const references = Object.create(null);
147
+ for (const [label, definition] of Object.entries(index.references)) {
148
+ const image = dataImage(definition.href);
149
+ references[label] = {href: image ? definition.href.slice(0, image.payloadStart) + 'AA==' : definition.href,
150
+ title: definition.title};
151
+ }
152
+ return {source: records.length ? parts.join('') : source, records, references};
153
+ }
154
+
132
155
  // The same index folded from the document's top-level blocks: `rows` are the blocks as markdown-it's block parse
133
156
  // of the body cuts them, each {start, raw} with `start` absolute in `source`, and `parse(raw, row)` is parseAssets
134
157
  // over one block (the caller may cache it by the row). A definition the whole parse finds is one a block's own parse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-markdown-kit",
3
- "version": "1.1.31",
3
+ "version": "1.1.32",
4
4
  "description": "Read, write and style Self-contained Markdown: the universal stylesheet, picture layout, text marks, picture appendix, line planner and Will/1 markers. MIT, no dependencies.",
5
5
  "author": "Jack Skipworth",
6
6
  "license": "MIT",