mdld-parse 1.0.3 → 1.0.5
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 +91 -28
- package/dist/index.js +61 -9
- package/package.json +33 -27
package/README.md
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
# MD-LD
|
|
2
2
|
|
|
3
|
-
**Markdown-Linked Data** —
|
|
3
|
+
**Markdown-Linked Data** — Write RDF knowledge graphs as plain Markdown. Parse to quads, generate back, merge documents. Zero dependencies, round-trip safe.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
MD-LD is the only RDF format that is both writable by humans and parseable by machines in the same document. Unlike Turtle (write-only), JSON-LD (machine-only), and RDFa (embedded-in-HTML-only), MD-LD annotations flow with natural Markdown prose — making knowledge graphs readable without a renderer.
|
|
6
6
|
|
|
7
|
-
[
|
|
7
|
+
**[mdld.js.org](https://mdld.js.org/)**
|
|
8
8
|
|
|
9
|
-
[
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## 📚 Documentation Hub
|
|
13
|
-
|
|
14
|
-
- **📋 [Specification](./spec/index.md)** — Formal specification and test suite
|
|
15
|
-
- **📖 [Documentation](./docs/index.md)** — Complete documentation with guides and references
|
|
16
|
-
- **🎯 [Examples](./examples/index.md)** — Real-world MD-LD examples and use cases
|
|
17
|
-
- **📚 [Grammar](./grammar/index.md)** — EBNF grammar specification
|
|
18
|
-
- **🧩 [Ontologies](./ontologies/index.md)** — W3C and related standard ontologies used in RDF
|
|
9
|
+
[](https://www.npmjs.com/package/mdld-parse/)
|
|
19
10
|
|
|
20
11
|
## 🎯 What is MD-LD?
|
|
21
12
|
|
|
@@ -34,18 +25,12 @@ Human text → Graph immediately
|
|
|
34
25
|
**Core value:** Author and maintain knowledge graphs as plain text with deterministic round-trip safety. No platforms, databases, or proprietary SaaS mediation required.
|
|
35
26
|
|
|
36
27
|
```markdown
|
|
37
|
-
[ex] <tag:
|
|
38
|
-
|
|
39
|
-
# My Bookmarks {=ex:bookmarks .prov:Entity .Container label}
|
|
40
|
-
|
|
41
|
-
> This is my first MD-LD document - a Bookmarks Collection {comment}
|
|
42
|
-
|
|
43
|
-
Created by [Alice] {+ex:alice ?ex:author .prov:Person label} at `2026-06-01T11:54:22.153Z` {prov:wasGeneratedAt ^^xsd:dateTime}.
|
|
28
|
+
[ex] <tag:ame@example.com,2026:>
|
|
44
29
|
|
|
45
|
-
|
|
30
|
+
# Alice {=ex:alice .prov:Person label}
|
|
46
31
|
|
|
47
|
-
[
|
|
48
|
-
[
|
|
32
|
+
[Alice Smith] {ex:fullName}
|
|
33
|
+
[alice@example.com] {ex:email}
|
|
49
34
|
```
|
|
50
35
|
|
|
51
36
|
**Generates RDF quads** that work with n3.js, rdflib, and any RDF/JS-compatible library.
|
|
@@ -97,6 +82,8 @@ MD-LD removes the intermediary. Writing becomes publishing. Publishing becomes g
|
|
|
97
82
|
- **Continuous semantic narrative** — Unifies chat, tasks, notes, emails, calendar, files
|
|
98
83
|
- **Native time dimension** — Every action, statement, correction becomes part of the graph
|
|
99
84
|
- **Decentralized authority** — RFC 4151 tag: URIs enable self-sovereign identity without central registries
|
|
85
|
+
- **Text-native agent memory** - LLM Agent memory substrate in plain text — parse context, write knowledge, merge with other agents, all as Markdown files. No database required.
|
|
86
|
+
|
|
100
87
|
|
|
101
88
|
### Real-World Applications
|
|
102
89
|
|
|
@@ -523,6 +510,80 @@ Comprehensive test suite covering:
|
|
|
523
510
|
- Round-trip parse/generate cycles
|
|
524
511
|
- Origin tracking and provenance
|
|
525
512
|
|
|
513
|
+
|
|
514
|
+
## 📚 Documentation Hub
|
|
515
|
+
|
|
516
|
+
- **📋 [Specification](./spec/index.md)** — Formal specification and test suite
|
|
517
|
+
- [Formal Specification](./spec/Spec.md)
|
|
518
|
+
- [Compact Spec](./spec/Spec-compact.md)
|
|
519
|
+
- [Ultra Compact Spec](./spec/Spec-ultra.md)
|
|
520
|
+
- **📚 [Grammar](./grammar/index.md)** — EBNF+TextMate grammar specifications
|
|
521
|
+
- [The TextMate grammar](./grammar/mdld.tmLanguage.json)
|
|
522
|
+
- [ISO 14977 EBNF grammar](./grammar/mdld.ebnf)
|
|
523
|
+
- **📖 [Documentation](./docs/index.md)** — Complete documentation with guides and references
|
|
524
|
+
- [MD-LD Authoring Guide](./docs/Guide.md)
|
|
525
|
+
- [One Page Guide](./docs/one-page.md)
|
|
526
|
+
- [Semantic Infrastructure as Readable Text](./docs/Semantic-Text.md)
|
|
527
|
+
- [Elevated Statements](./docs/statements.md)
|
|
528
|
+
- [Primary Metadata System](./docs/primary-subject.md)
|
|
529
|
+
- [Origin System](./docs/origin.md)
|
|
530
|
+
- [Polarity & Retraction](./docs/polarity.md)
|
|
531
|
+
- [Subject System](./docs/Subject.md)
|
|
532
|
+
- [API Reference](./docs/API.md)
|
|
533
|
+
- [Generate: Quads to MDLD](./docs/generate.md)
|
|
534
|
+
- [Diff Documents](./docs/diff.md)
|
|
535
|
+
- [Syntax Reference](./docs/Syntax.md)
|
|
536
|
+
- [Architecture & Design](./docs/Architecture.md)
|
|
537
|
+
- [Parser Architecture](./docs/Parser.md)
|
|
538
|
+
- [Performance Benchmarks](./docs/Performance.md)
|
|
539
|
+
- [Token Efficiency](./docs/Token-Efficiency.md)
|
|
540
|
+
- [Knowledge Round Trip](./docs/Knowledge-Round-Trip.md)
|
|
541
|
+
- [Human-Scale Software & Semantic Infrastructure](./docs/Human-Scale.md)
|
|
542
|
+
- [Quad[] as a Universal Semantic Runtime](./docs/quad-runtime.md)
|
|
543
|
+
- [Use Cases](./docs/Use-Cases.md)
|
|
544
|
+
- **🎯 [Examples](./examples/index.md)** — Real-world MD-LD examples and use cases
|
|
545
|
+
- [Minimal](./examples/demo/minimal.md)
|
|
546
|
+
- [One-Page Guide](./examples/one-page.md)
|
|
547
|
+
- [Few-Shot Examples](./examples/few-shot.md)
|
|
548
|
+
- [Journal](./examples/demo/journal.md)
|
|
549
|
+
- [Tasks](./examples/demo/tasks.md)
|
|
550
|
+
- [Medical AI Research](./examples/demo/research.md)
|
|
551
|
+
- [Cookbook](./examples/Cookbook.md)
|
|
552
|
+
- [Website Redesign Project](./examples/demo/project.md)
|
|
553
|
+
- [Task Management System](./examples/demo/tasks.md)
|
|
554
|
+
- [Cassini-Huygens Mission](./examples/demo/space-mission.md)
|
|
555
|
+
- [RDF Fundamentals](./examples/demo/rdf.md)
|
|
556
|
+
- [PROV-O Patterns](./examples/demo/prov.md)
|
|
557
|
+
- [SHACL Validation](./examples/demo/shacl.md)
|
|
558
|
+
- [XSD Datatypes](./examples/demo/xsd.md)
|
|
559
|
+
- [Status & SHACL Validation](./examples/Status-SHACL.md)
|
|
560
|
+
- [LLM Time Workflow](./examples/llm-time-workflow.md)
|
|
561
|
+
- [Research Workflow](./examples/workflow.md)
|
|
562
|
+
- [Dogfood](./examples/dogfood.md)
|
|
563
|
+
- **🧩 [Ontologies](./ontologies/index.md)** — W3C and related standard ontologies used in RDF
|
|
564
|
+
- [RDF — Resource Description Framework](./ontologies/rdf.md)
|
|
565
|
+
- [RDFS — RDF Schema](./ontologies/rdfs.md)
|
|
566
|
+
- [SHACL — Shapes Constraint Language](./ontologies/shacl.md)
|
|
567
|
+
- [PROV-O — W3C Provenance Ontology](./ontologies/prov-o.md)
|
|
568
|
+
- [XSD — XML Schema Definition Datatypes](./ontologies/xsd.md)
|
|
569
|
+
- [DCTERMS — Dublin Core Metadata Terms](./ontologies/dcterms.md)
|
|
570
|
+
- [DCAT — Data Catalog Vocabulary](./ontologies/dcat.md)
|
|
571
|
+
- [FOAF — Friend of a Friend](./ontologies/foaf.md)
|
|
572
|
+
- [VCard](./ontologies/vcard.md)
|
|
573
|
+
- [Time — OWL-Time Ontology](./ontologies/time.md)
|
|
574
|
+
- [Activity Streams 2.0](./ontologies/activity-streams-2.md)
|
|
575
|
+
- [SKOS — Simple Knowledge Organization System](./ontologies/skos.md)
|
|
576
|
+
- [Schema.org](./ontologies/schemaorg.md)
|
|
577
|
+
- [CIDOC CRM — Conceptual Reference Model](./ontologies/cidoc_crm.md)
|
|
578
|
+
- [SOSA — Sensor, Observation, Sample, and Actuator](./ontologies/sosa.md)
|
|
579
|
+
- [QUDT — Quantities, Units, Dimensions and Types](./ontologies/qudt.md)
|
|
580
|
+
- [GOLD — General Ontology for Linguistic Description](./ontologies/gold.md)
|
|
581
|
+
- [LexInfo — Lexical Information Ontology](./ontologies/lexinfo.md)
|
|
582
|
+
- [OWL — Web Ontology Language](./ontologies/owl.md)
|
|
583
|
+
- [P-PLAN — Plan Ontology](./ontologies/p-plan.md)
|
|
584
|
+
- [Hydra — Hypermedia API Vocabulary](./ontologies/hydra.md)
|
|
585
|
+
- [Web Annotations](./ontologies/web-annotations.md)
|
|
586
|
+
|
|
526
587
|
## Governance
|
|
527
588
|
|
|
528
589
|
MD-LD is a craft project. Its coherence comes from a single evolving understanding of how semantic text should work — not from consensus, but from sustained attention to the same problem over time.
|
|
@@ -537,12 +598,14 @@ This means:
|
|
|
537
598
|
|
|
538
599
|
## Licensing
|
|
539
600
|
|
|
540
|
-
MD-LD is published as copyrighted source material.
|
|
601
|
+
MD-LD is currently published as copyrighted source material.
|
|
602
|
+
|
|
603
|
+
The project is under active development and no open-source license has been selected yet.
|
|
541
604
|
|
|
542
|
-
|
|
605
|
+
Individuals, researchers, educators, and non-commercial users are welcome to experiment with the technology.
|
|
543
606
|
|
|
544
|
-
|
|
607
|
+
Organizations interested in production or commercial use should contact the author.
|
|
545
608
|
|
|
546
|
-
|
|
609
|
+
The long-term governance and licensing model remains under evaluation.
|
|
547
610
|
|
|
548
|
-
|
|
611
|
+
The primary goal at this stage is preserving the simplicity, interoperability, and long-term integrity of the system while the ecosystem forms around it.
|
package/dist/index.js
CHANGED
|
@@ -133,10 +133,12 @@ var DataFactory = {
|
|
|
133
133
|
let datatype = languageOrDataType ? languageOrDataType.value : "";
|
|
134
134
|
if (datatype === "") {
|
|
135
135
|
if (typeof value === "boolean") datatype = XSD_BOOLEAN;
|
|
136
|
-
else if (typeof value === "number")
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
else if (typeof value === "number") {
|
|
137
|
+
if (Number.isFinite(value)) datatype = Number.isInteger(value) ? XSD_INTEGER : XSD_DOUBLE;
|
|
138
|
+
else {
|
|
139
|
+
datatype = XSD_DOUBLE;
|
|
140
|
+
if (!Number.isNaN(value)) value = value > 0 ? "INF" : "-INF";
|
|
141
|
+
}
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
return datatype === "" || datatype === "http://www.w3.org/2001/XMLSchema#string" ? new Literal(`"${escapedValue}"`) : new Literal(`"${escapedValue}"^^${datatype}`);
|
|
@@ -773,9 +775,7 @@ function scanInlineCarriers(text, baseOffset = 0) {
|
|
|
773
775
|
case "_":
|
|
774
776
|
detected = detectEmphasis(text, pos);
|
|
775
777
|
break;
|
|
776
|
-
case "`":
|
|
777
|
-
detected = detectCodeSpan(text, pos);
|
|
778
|
-
break;
|
|
778
|
+
case "`": detected = detectCodeSpan(text, pos);
|
|
779
779
|
}
|
|
780
780
|
if (!detected) {
|
|
781
781
|
pos++;
|
|
@@ -1122,6 +1122,48 @@ function scanTokens(text) {
|
|
|
1122
1122
|
const lines = text.split("\n");
|
|
1123
1123
|
let pos = 0;
|
|
1124
1124
|
let codeBlock = null;
|
|
1125
|
+
let sfcBlock = null;
|
|
1126
|
+
function detectSfcStart(trimmed) {
|
|
1127
|
+
if (trimmed.startsWith("<!--")) return true;
|
|
1128
|
+
return /^<(script|style|template)\b/i.test(trimmed);
|
|
1129
|
+
}
|
|
1130
|
+
function checkSfcClose(line) {
|
|
1131
|
+
if (!sfcBlock) return;
|
|
1132
|
+
if (sfcBlock.tag === "comment") {
|
|
1133
|
+
if (line.includes("-->")) sfcBlock = null;
|
|
1134
|
+
} else if (sfcBlock.tag === "script" || sfcBlock.tag === "style") {
|
|
1135
|
+
if (new RegExp(`</\\s*${sfcBlock.tag}\\s*>`, "i").test(line)) sfcBlock = null;
|
|
1136
|
+
} else if (sfcBlock.tag === "template") {
|
|
1137
|
+
const openMatches = (line.match(/<template\b/gi) || []).length;
|
|
1138
|
+
const closeMatches = (line.match(/<\/template>/gi) || []).length;
|
|
1139
|
+
sfcBlock.depth += openMatches - closeMatches;
|
|
1140
|
+
if (sfcBlock.depth <= 0) sfcBlock = null;
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
function handleSfcStart(line) {
|
|
1144
|
+
const trimmed = line.trim();
|
|
1145
|
+
if (trimmed.startsWith("<!--")) sfcBlock = {
|
|
1146
|
+
tag: "comment",
|
|
1147
|
+
depth: 1
|
|
1148
|
+
};
|
|
1149
|
+
else {
|
|
1150
|
+
const match = trimmed.match(/^<(script|style|template)\b/i);
|
|
1151
|
+
if (!match) return false;
|
|
1152
|
+
const tag = match[1].toLowerCase();
|
|
1153
|
+
sfcBlock = {
|
|
1154
|
+
tag,
|
|
1155
|
+
depth: tag === "template" ? 0 : 1
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
mdLines.push(line);
|
|
1159
|
+
checkSfcClose(line);
|
|
1160
|
+
return true;
|
|
1161
|
+
}
|
|
1162
|
+
function handleSfcContent(line) {
|
|
1163
|
+
mdLines.push(line);
|
|
1164
|
+
checkSfcClose(line);
|
|
1165
|
+
return true;
|
|
1166
|
+
}
|
|
1125
1167
|
const PROCESSORS = [
|
|
1126
1168
|
{
|
|
1127
1169
|
type: "fence",
|
|
@@ -1129,10 +1171,20 @@ function scanTokens(text) {
|
|
|
1129
1171
|
process: handleFence
|
|
1130
1172
|
},
|
|
1131
1173
|
{
|
|
1132
|
-
type: "
|
|
1174
|
+
type: "codeContent",
|
|
1133
1175
|
test: () => codeBlock,
|
|
1134
1176
|
process: (line) => codeBlock.content.push(line)
|
|
1135
1177
|
},
|
|
1178
|
+
{
|
|
1179
|
+
type: "sfcContent",
|
|
1180
|
+
test: () => sfcBlock,
|
|
1181
|
+
process: handleSfcContent
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
type: "sfcStart",
|
|
1185
|
+
test: (line) => detectSfcStart(line.trim()),
|
|
1186
|
+
process: handleSfcStart
|
|
1187
|
+
},
|
|
1136
1188
|
{
|
|
1137
1189
|
type: "prefix",
|
|
1138
1190
|
test: (line) => detectPrefix(line),
|
|
@@ -1837,7 +1889,7 @@ function groupQuadsByNode(quads) {
|
|
|
1837
1889
|
else reverseIndex.set(objectValue, [quad]);
|
|
1838
1890
|
}
|
|
1839
1891
|
ensure(predicate.value).push(quad);
|
|
1840
|
-
if (predicate.value ===
|
|
1892
|
+
if (predicate.value === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" && object.termType === "NamedNode") ensure(object.value).push(quad);
|
|
1841
1893
|
if (object.termType === "Literal" && object.datatype) ensure(object.datatype.value || object.datatype).push(quad);
|
|
1842
1894
|
}
|
|
1843
1895
|
return {
|
package/package.json
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdld-parse",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "Write RDF knowledge graphs as plain Markdown. Parse to quads, generate back, merge documents. The human-friendly semantic web format.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"rdf",
|
|
7
|
+
"linked-data",
|
|
8
|
+
"semantic-web",
|
|
9
|
+
"knowledge-graph",
|
|
10
|
+
"markdown",
|
|
11
|
+
"semantic-annotations",
|
|
12
|
+
"provenance",
|
|
13
|
+
"prov-o",
|
|
14
|
+
"shacl",
|
|
15
|
+
"agent-memory",
|
|
16
|
+
"llm",
|
|
17
|
+
"md-ld",
|
|
18
|
+
"mdld",
|
|
19
|
+
"semantic-markdown",
|
|
20
|
+
"quad-store",
|
|
21
|
+
"crdt",
|
|
22
|
+
"rdfs",
|
|
23
|
+
"ontology",
|
|
24
|
+
"triple-store"
|
|
25
|
+
],
|
|
5
26
|
"type": "module",
|
|
6
|
-
"packageManager": "pnpm@
|
|
27
|
+
"packageManager": "pnpm@11.24.0+sha512.bd27e345e976dcb0be0b7a1228217b049a817e21b1f355c90dbe7dc46671895a8bc1e6d06c24554505ea93ea0b45f489a27ec1bfbc8de6a9659fca0f16fa0000",
|
|
7
28
|
"main": "./dist/index.js",
|
|
8
29
|
"exports": {
|
|
9
30
|
".": "./dist/index.js"
|
|
@@ -16,21 +37,6 @@
|
|
|
16
37
|
"dev": "vite dev",
|
|
17
38
|
"build": "vite build && vite build --config vite.config.lib.js && cp -r docs/ dist/docs/ && cp -r examples/ dist/examples/ && cp -r grammar/ dist/grammar/ && cp -r ontologies/ dist/ontologies/ && cp -r spec/ dist/spec/ && cp -r README.md dist/README.md && cp -r docs.html dist/docs.html && cp -r demo/ dist/demo/"
|
|
18
39
|
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"mdld",
|
|
21
|
-
"markdown",
|
|
22
|
-
"rdf",
|
|
23
|
-
"semantic-web",
|
|
24
|
-
"linked-data",
|
|
25
|
-
"n3",
|
|
26
|
-
"rdfjs",
|
|
27
|
-
"browser",
|
|
28
|
-
"web-worker",
|
|
29
|
-
"parser",
|
|
30
|
-
"prefix-folding",
|
|
31
|
-
"curie",
|
|
32
|
-
"iri-authoring"
|
|
33
|
-
],
|
|
34
40
|
"author": "davay42",
|
|
35
41
|
"repository": {
|
|
36
42
|
"type": "git",
|
|
@@ -41,17 +47,17 @@
|
|
|
41
47
|
"url": "https://github.com/davay42/mdld-parse/issues"
|
|
42
48
|
},
|
|
43
49
|
"devDependencies": {
|
|
44
|
-
"@unocss/extractor-pug": "^66.
|
|
45
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
46
|
-
"@vueuse/core": "^14.
|
|
50
|
+
"@unocss/extractor-pug": "^66.8.1",
|
|
51
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
52
|
+
"@vueuse/core": "^14.4.0",
|
|
47
53
|
"codejar": "^4.3.0",
|
|
48
|
-
"markdown-it": "^
|
|
49
|
-
"n3": "^2.0
|
|
50
|
-
"shiki": "^4.
|
|
51
|
-
"unocss": "^66.
|
|
52
|
-
"vite": "^8.
|
|
54
|
+
"markdown-it": "^15.0.0",
|
|
55
|
+
"n3": "^2.6.0",
|
|
56
|
+
"shiki": "^4.4.3",
|
|
57
|
+
"unocss": "^66.8.1",
|
|
58
|
+
"vite": "^8.2.2",
|
|
53
59
|
"vite-plugin-singlefile": "^2.3.3",
|
|
54
60
|
"vscode-textmate": "^9.3.2",
|
|
55
|
-
"vue": "^3.6.0-beta.
|
|
61
|
+
"vue": "^3.6.0-beta.17"
|
|
56
62
|
}
|
|
57
63
|
}
|