mdld-parse 1.1.1 → 1.1.3

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 CHANGED
@@ -58,24 +58,31 @@ Or use `importmap` in the browser:
58
58
 
59
59
 
60
60
  ```javascript
61
- import { parse, generate, merge, render, deconstruct } from 'mdld-parse';
61
+ import { parse, generate, merge, render, deconstruct, highlight } from 'mdld-parse';
62
62
 
63
63
  // Parse MDLD to RDF quads
64
- const result = parse({ text: mdldString });
65
- console.log(result.quads); // RDF/JS quads
66
- console.log(result.primary); // Primary metadata (subject, type, label, comment)
67
- console.log(result.statements); // Elevated statements
68
- console.log(result.origin); // Provenance tracking
64
+ const { quads, primary, statements, origin } = parse({ text: mdldString });
65
+ console.log(quads); // RDF/JS quads
66
+ console.log(primary); // Primary metadata (subject, type, label, comment)
67
+ console.log(statements); // Elevated statements
68
+ console.log(origin); // Provenance tracking
69
69
 
70
70
  // Generate MDLD from quads
71
- const { text } = generate({ quads: result.quads });
71
+ const { text } = generate({ quads });
72
+
73
+ // Highlight MDLD text with syntax coloring
74
+ const highlighted = highlight(text);
72
75
 
73
76
  // Render to semantic HTML with preserved annotations
74
- const html = render(mdldString);
77
+ const html = render(text);
75
78
 
76
79
  // Reconstruct MDLD from HTML (lossless roundtrip)
77
80
  const reconstructed = deconstruct(html);
78
- const quads = parse(reconstructed).quads; // Same quads as original!
81
+ const reconstructedQuads = parse(reconstructed).quads; // Same quads as original!
82
+
83
+ // Verify roundtrip integrity by using generate() as canonicalization
84
+ const canonical = generate({ quads: reconstructedQuads });
85
+ console.log('Roundtrip preserved:', text === canonical.text);
79
86
 
80
87
  // Lossy rendering for privacy-preserving publishing
81
88
  const cleanHtml = render(parse(mdldString).md);
@@ -442,6 +449,8 @@ Generate deterministic MDLD from RDF quads.
442
449
 
443
450
  **Features:** Visual styling, label-in-heading, round-trip safe, diff generation, language preference.
444
451
 
452
+ **Canonical output:** `generate()` is a deterministic serializer — quads are normalized into a total order (subject → predicate → object → term type → datatype → language) before rendering, so the same quad *set* always produces byte-identical text regardless of input array order. This makes it usable for RDF graph comparison: `generate(g1).text === generate(g2).text` iff the graphs are equal (modulo blank nodes, which are out of scope, and named graphs, which MD-LD does not serialize). Note that options (`context`, `primarySubject`, `compactInline`, `renderReverse`, `lang`, `remove`) are part of the canonical form — compare outputs generated with the same options.
453
+
445
454
  **Example with language preference:**
446
455
  ```javascript
447
456
  const { text } = generate({
package/dist/crawl.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/crawl.js
1
+ // src/crawl.js
2
2
  /**
3
3
  * crawl — a platform-agnostic linked-text-document crawler.
4
4
  *
@@ -656,5 +656,4 @@ async function crawl(startUrl, options = {}) {
656
656
  * status?: number, message: string}>} errors
657
657
  * @property {boolean} aborted
658
658
  */
659
- //#endregion
660
659
  export { crawl, extractLinks, memoryCache };