rapier-markdown-kit 1.2.15 → 1.2.17

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.
@@ -5,6 +5,8 @@ export interface DocumentParts { ledger?: LedgerEnvelope | null; authorship?: Au
5
5
  export interface ReadParts { text: string; ledger: LedgerEnvelope | null; authorship: AuthorshipEnvelope | null; }
6
6
  /** The text with its parts appended as one EOF comment; the text alone when there are none. */
7
7
  export function writeDocument(text: string, parts?: DocumentParts): string;
8
+ /** The verified EOF comment without copying the source; empty when there are no carried parts. */
9
+ export function documentTrailer(text: string, parts?: DocumentParts): string;
8
10
  /** Splits a saved file into its exact text and verified parts; throws on a damaged or mismatched comment. */
9
11
  export function readDocument(source: string): ReadParts;
10
12
  export function writeParts(text: string, parts?: DocumentParts): string;
@@ -47,11 +47,14 @@ export function takeParts(html, text) {
47
47
  return {html: stripped, ...readParts(text ?? '', elements)};
48
48
  }
49
49
  const OPEN = '\n\n<!-- rapier-carried/1\n', CLOSE = '\n-->\n';
50
- export function writeDocument(text, options) {
50
+ export function documentTrailer(text, options) {
51
51
  const parts = validateParts(text, options);
52
- if (!parts.ledger && !parts.authorship) return text;
52
+ if (!parts.ledger && !parts.authorship) return '';
53
53
  const json = JSON.stringify(parts).replace(/</g, '\\u003c').replace(/>/g, '\\u003e');
54
- return text + OPEN + json + CLOSE;
54
+ return OPEN + json + CLOSE;
55
+ }
56
+ export function writeDocument(text, options) {
57
+ return text + documentTrailer(text, options);
55
58
  }
56
59
  export function readDocument(source) {
57
60
  if (!source.endsWith(CLOSE)) {
@@ -10,8 +10,8 @@ export {_rapierTransformSplices, _rapierRecordSplices, _rapierValidLedgerRecord,
10
10
  import {replayHistory, sourceBefore, historyProjection, historyProjections, historyPlaces, selectiveUndo, groupHistoryActs, pictureHistorySplices} from './ledger/history.mjs';
11
11
  export {replayHistory, sourceBefore, historyProjection, historyProjections, historyPlaces, selectiveUndo, groupHistoryActs, pictureHistorySplices};
12
12
 
13
- import {sha256State} from './ledger/hash.mjs';
14
- export {sha256State};
13
+ import {sha256State, sha256} from './ledger/hash.mjs';
14
+ export {sha256State, sha256};
15
15
  import {transposeSource} from './ledger/transport.mjs';
16
16
  export {transposeSource};
17
17
 
@@ -928,13 +928,13 @@ function* _rapierMarkFigureCaptionsSteps(root) {
928
928
  }
929
929
  }
930
930
 
931
- function _rapierMarkListContinuations(blocks) { return finish(_rapierMarkListContinuationsSteps(blocks)); }
931
+ function _rapierMarkListContinuations(blocks, mark) { return finish(_rapierMarkListContinuationsSteps(blocks, mark)); }
932
932
 
933
933
  function* _rapierChildElements(root) {
934
934
  for (let child = root.firstElementChild; child; child = child.nextElementSibling) yield child;
935
935
  }
936
936
 
937
- function* _rapierMarkListContinuationsSteps(blocks) {
937
+ function* _rapierMarkListContinuationsSteps(blocks, mark = (element, name) => element.setAttribute(name, '')) {
938
938
  const isHeading = element => !!element && /^H[1-6]$/.test(element.tagName);
939
939
  let previous = null, headings = [], last = 0;
940
940
  for (const element of blocks) { yield;
@@ -942,8 +942,8 @@ function* _rapierMarkListContinuationsSteps(blocks) {
942
942
  if (!element || element.tagName !== 'OL') {previous = null; headings = []; continue;}
943
943
  const start = parseInt(element.getAttribute('start'), 10);
944
944
  if (previous && headings.length && start === last + 1) {
945
- previous.setAttribute('data-rapier-list-continues', '');
946
- for (const heading of headings) { yield;heading.setAttribute('data-rapier-list-through', '');}
945
+ mark(previous, 'data-rapier-list-continues');
946
+ for (const heading of headings) { yield;mark(heading, 'data-rapier-list-through');}
947
947
  }
948
948
  previous = element; headings = [];
949
949
  last = (Number.isFinite(start) ? start : 1) + element.querySelectorAll(':scope > li').length - 1;
@@ -302,7 +302,9 @@ export function createTypography() {
302
302
  !['static','relative'].includes(s.position) || element !== paragraph && element.tagName !== 'BR' && s.display !== 'inline' ||
303
303
  !['none','normal'].includes(before) || !['none','normal'].includes(after)) supported = false;
304
304
  }
305
- keys.push(...attributes.map(name => paragraph.getAttribute(name)));
305
+ const sourceStyle = value => value == null ? null : value.split(';').map(part => part.trim())
306
+ .filter(part => part && !properties.some(name => part.startsWith(name + ':'))).join(';');
307
+ keys.push(...attributes.map(name => name === 'style' ? sourceStyle(paragraph.getAttribute(name)) : paragraph.getAttribute(name)));
306
308
  return {key: keys.join('\u0000'), generation:keys[0], styles, parents, supported};
307
309
  }
308
310
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapier-markdown-kit",
3
- "version": "1.2.15",
3
+ "version": "1.2.17",
4
4
  "description": "Read, render and write Self-contained Markdown: one .md file that carries its pictures, drawings and layout, and that any Markdown app can read. HTML renderer, stylesheet, text layout, Will/1 agent permissions, and an edit history with authorship and offline merge. MIT, no dependencies.",
5
5
  "keywords": [
6
6
  "markdown",