mdld-parse 1.1.0 → 1.1.2
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 +18 -0
- package/dist/crawl.js +1 -2
- package/dist/mdld-parse.js +807 -431
- package/dist/quad-graph.js +132 -23
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -442,6 +442,8 @@ Generate deterministic MDLD from RDF quads.
|
|
|
442
442
|
|
|
443
443
|
**Features:** Visual styling, label-in-heading, round-trip safe, diff generation, language preference.
|
|
444
444
|
|
|
445
|
+
**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.
|
|
446
|
+
|
|
445
447
|
**Example with language preference:**
|
|
446
448
|
```javascript
|
|
447
449
|
const { text } = generate({
|
|
@@ -501,6 +503,10 @@ Convert MD-LD to semantic HTML with preserved annotations.
|
|
|
501
503
|
- Preserves complete MD-LD syntax in `data-annotation` for roundtrip reconstruction
|
|
502
504
|
- Resolves IRIs into `data-iri` attributes for easy querying
|
|
503
505
|
- Adds semantic CSS classes: `.mdld-heading`, `.mdld-link`, `.typed`, `.retracted`
|
|
506
|
+
- External links (`http(s)://`, `mailto:`, any scheme, protocol-relative) get `target="_blank" rel="noopener noreferrer"`; fragment (`#`) and relative links stay on-page
|
|
507
|
+
- Full CommonMark inline links: `[text](#fragment)`, `[text](/path)`, `[text](mailto:…)`, titles (`[t](url "title")`), and images ``
|
|
508
|
+
- Entity references (`&`, `©`, `©`, `©`) decode; backslash escapes (`\*`) suppress markup
|
|
509
|
+
- Standard Markdown/HTML passthrough: raw HTML blocks (`<table>`, `<div>`, …), inline HTML, hard breaks (`<br />`), and indented code blocks render per CommonMark; code stays escaped
|
|
504
510
|
- Platform-agnostic: works in Node.js, Deno, browsers, edge workers
|
|
505
511
|
|
|
506
512
|
**Example:**
|
|
@@ -540,6 +546,18 @@ const mdld = deconstruct(html);
|
|
|
540
546
|
- Client-side graph extraction: `parse(deconstruct(document.body.innerHTML))`
|
|
541
547
|
- Offline-first apps: cache HTML, reconstruct quads on demand
|
|
542
548
|
|
|
549
|
+
**Notes:**
|
|
550
|
+
- Raw HTML blocks pass through `deconstruct()` verbatim, so `<table>` and friends roundtrip losslessly
|
|
551
|
+
- `deconstruct()` only recognizes elements carrying `mdld-*` classes — hand-written HTML without them is treated as raw passthrough
|
|
552
|
+
|
|
553
|
+
**CommonMark compatibility — deliberate limitations:**
|
|
554
|
+
- **Setext headings** (`Title` + `===`/`---`) are not supported: they need lookahead that conflicts with per-line annotation parsing, and `---` already means `<hr>`. Use ATX `#` headings.
|
|
555
|
+
- **Reference-style links** (`[text][ref]`, `[ref]: url`) are not supported: definitions require document-level state that wouldn't survive `deconstruct()` round-trips anyway. Use inline `[text](url)`.
|
|
556
|
+
- **Shortcut references** (`[ref]` alone as a link) conflict with MD-LD's `[text]` bracket-span syntax.
|
|
557
|
+
- **GFM extensions** (pipe tables, `~~strikethrough~~`, task lists, `www.` autolinks) are out of scope — use raw HTML for tables.
|
|
558
|
+
- Combined emphasis `***text***` renders as `*<strong>text</strong>*`, not nested `<em><strong>`.
|
|
559
|
+
- Empty link destinations `[text]()` stay literal; indented code inside list items is not recognized; inline HTML tags are dropped by `deconstruct()` (inner text preserved).
|
|
560
|
+
|
|
543
561
|
## 🎨 Graph Visualization — `<quad-graph>`
|
|
544
562
|
|
|
545
563
|
Visualize your RDF quads as an interactive force-directed graph with the zero-dependency `<quad-graph>` web component.
|
package/dist/crawl.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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 };
|