mdld-parse 0.9.2 → 0.9.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/dist/.nojekyll +0 -0
- package/dist/CNAME +1 -0
- package/dist/README.md +425 -0
- package/dist/docs/API.md +397 -0
- package/dist/docs/Architecture.md +190 -0
- package/dist/docs/Guide.md +322 -0
- package/dist/docs/LLM-MDLD-Inducer.md +550 -0
- package/dist/docs/Parser.md +654 -0
- package/dist/docs/Performance.md +238 -0
- package/dist/docs/Spec-render.md +1439 -0
- package/dist/docs/Subject.md +180 -0
- package/dist/docs/Syntax.md +463 -0
- package/dist/docs/TodoList.md +215 -0
- package/dist/docs/Use-Cases.md +354 -0
- package/dist/docs/index.html +108 -0
- package/dist/docs/index.md +56 -0
- package/dist/docs/origin.md +459 -0
- package/dist/docs/polarity.md +586 -0
- package/dist/docs/primary-subject.md +199 -0
- package/dist/docs/statements.md +226 -0
- package/dist/docs/tokenization-performance-report.md +164 -0
- package/dist/examples/Cookbook.md +32 -0
- package/dist/examples/Status-SHACL.md +33 -0
- package/dist/examples/demo/index.md +35 -0
- package/dist/examples/demo/journal.md +18 -0
- package/dist/examples/demo/minimal.md +11 -0
- package/dist/examples/demo/project.md +15 -0
- package/dist/examples/demo/recipe.md +31 -0
- package/dist/examples/demo/research.md +46 -0
- package/dist/examples/demo/space-mission.md +48 -0
- package/dist/examples/dogfood.md +288 -0
- package/dist/examples/few-shot.md +309 -0
- package/dist/examples/graph/rdf-graph.html +473 -0
- package/dist/examples/graph/rdf_force_graph_web_component.html +506 -0
- package/dist/examples/index.md +45 -0
- package/dist/examples/llm-time-workflow.md +173 -0
- package/dist/examples/prov-o.md +2367 -0
- package/dist/examples/rdf.md +827 -0
- package/dist/examples/shacl.md +3399 -0
- package/dist/examples/statements.md +43 -0
- package/dist/examples/workflow.md +150 -0
- package/dist/index.html +2827 -0
- package/dist/index.js +1548 -0
- package/dist/logo.svg +7 -0
- package/dist/spec/Spec-compact.md +363 -0
- package/dist/spec/Spec-ultra.md +221 -0
- package/dist/spec/Spec.md +1068 -0
- package/dist/spec/index.md +46 -0
- package/package.json +7 -8
- package/src/constants.js +0 -31
- package/src/generate.js +0 -245
- package/src/highlight.js +0 -362
- package/src/index.js +0 -13
- package/src/locate.js +0 -23
- package/src/merge.js +0 -157
- package/src/parse.js +0 -711
- package/src/render.js +0 -576
- package/src/shared.js +0 -577
- package/src/tokenizers.js +0 -594
- package/src/utils.js +0 -430
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[my] <tag:alice@example.com,2026:journal:2026-07-18:>
|
|
2
|
+
|
|
3
|
+
## July 18, 2026 {=my:day .prov:Activity label}
|
|
4
|
+
|
|
5
|
+
Great day! Mood: [happy] {my:mood}, energy: [8/10] {my:energy ^^xsd:integer}.
|
|
6
|
+
|
|
7
|
+
Location: [Central Park] {+my:park ?prov:atLocation .prov:Location label}.
|
|
8
|
+
|
|
9
|
+
Feeling [peaceful] {my:feeling} today. The park was [beautiful] {my:description}.
|
|
10
|
+
|
|
11
|
+
**Morning walk** {=my:walk .prov:Activity label} - 45 minutes, 2.5 miles. Used [running shoes] {+my:shoes ?prov:used}. Generated [heart rate data] {+my:hr ?prov:generated}.
|
|
12
|
+
|
|
13
|
+
**Reading Dune** {=my:reading .prov:Activity label} - page [42] {my:page ^^xsd:integer} of 412. Used [book] {+my:book ?prov:used}.
|
|
14
|
+
|
|
15
|
+
Met [Sam] {+my:sam .prov:Person label} for coffee. **Chat** {=my:chat .prov:Activity label} - career changes topic, 30 mins.
|
|
16
|
+
|
|
17
|
+
**Coffee** {=my:coffee .prov:Activity label} at [home] {+my:home ?prov:atLocation}. Black, 12 oz.
|
|
18
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[my] <tag:alice@example.com,2026:>
|
|
2
|
+
|
|
3
|
+
# Machine Learning in Healthcare {=my:paper .prov:Entity label}
|
|
4
|
+
|
|
5
|
+
Pages: [24] {my:pages ^^xsd:integer}
|
|
6
|
+
DOI: [10.1234/ml.2024] {+https://doi.org/10.1234/ml.2024 ?my:doi}
|
|
7
|
+
|
|
8
|
+
Created by [Dr. Alice Chen] {+my:alice .prov:Person ?prov:wasAttributedTo label}.
|
|
9
|
+
|
|
10
|
+
**Attribution** {=my:attr .prov:Attribution ?prov:qualifiedAttribution label}: Created by [Dr. Alice Chen] {+my:alice ?prov:agent} as a [Lead Author] {+my:role .prov:Role ?prov:hadRole}.
|
|
11
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[proj] <tag:alice@example.com,2026:project/>
|
|
2
|
+
|
|
3
|
+
## Weekend Project {=proj:weekend .prov:Activity label}
|
|
4
|
+
|
|
5
|
+
Project manager [Alice] {+proj:alice .prov:Person ?prov:wasAssociatedWith}.
|
|
6
|
+
|
|
7
|
+
The project includes [kitchen cleaning] {+proj:clean .proj:Task label} with subtasks: countertops, dishes, and pantry organization. Also includes [bike repair] {+proj:bike .proj:Task label} involving tire pressure, brakes, and chain maintenance. Finally, [reading] {+proj:read .proj:Task label} covers chapters 1-6.
|
|
8
|
+
|
|
9
|
+
**Delegation** {=proj:delegation .prov:Delegation ?prov:qualifiedDelegation}
|
|
10
|
+
|
|
11
|
+
Resources needed: [hardware store] {+proj:hardware .proj:Resource} for screws and bike pump, and [GitHub repo] {+proj:repo .proj:Repository} for source code and documentation.
|
|
12
|
+
|
|
13
|
+
Team: [Alice] {+proj:alice ?prov:agent} as project manager with planning skill, [Bob] {+proj:bob ?prov:agent .prov:Person} as helper with bike repair skill.
|
|
14
|
+
|
|
15
|
+
The project has a [rain forecast] {+proj:rain !proj:blocker .proj:Blocker} blocker, with [indoor work] {+proj:indoor ?proj:alternative} as an alternative.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
[food] <tag:alice@example.com,2026:food/>
|
|
2
|
+
|
|
3
|
+
## Apple Pie {=food:pie .prov:Entity label}
|
|
4
|
+
|
|
5
|
+
Grandma Rose's recipe, documented by Alice. Cook time: [45] {food:time ^^xsd:integer} min, serves [8] {food:serves ^^xsd:integer}.
|
|
6
|
+
|
|
7
|
+
**Ingredients**
|
|
8
|
+
|
|
9
|
+
Flour (cups): [2.5] {+#flour ?food:ingredient .food:Ingredient food:ammount ^^food:cup} - used in crust
|
|
10
|
+
|
|
11
|
+
Sugar (cups): `1` {+#sugar ?food:ingredient .food:Ingredient food:ammount ^^food:cup} used in filling
|
|
12
|
+
|
|
13
|
+
Butter (cups): *1* {+#butter ?food:ingredient .food:Ingredient food:ammoun ^^food:cupt} used in crust
|
|
14
|
+
|
|
15
|
+
Apples: **6** {+#apples ?food:ingredient .food:Ingredient food:ammount ^^xsd:integer} used in filling
|
|
16
|
+
|
|
17
|
+
Cinnamon (tsp): __2__ {+food:cinnamon ?food:ingredient .food:Ingredient ^^xsd:tsp} used in filling
|
|
18
|
+
|
|
19
|
+
**Process**
|
|
20
|
+
|
|
21
|
+
**Crust** {=food:crust .prov:Activity} mixed [flour] {+food:pie#flour ?prov:used} and [butter] {+food:pie#butter}, generated [dough] {+food:dough ?prov:generated}. Used [bowl] {+food:bowl ?prov:used}.
|
|
22
|
+
|
|
23
|
+
**Filling** {=food:filling .prov:Activity ?prov:wasInformedBy} prepared apples with sugar and cinnamon, generated [apple mix] {+food:mix ?prov:generated}.
|
|
24
|
+
|
|
25
|
+
**Baking** {=food:bake .prov:Activity ?prov:wasInformedBy} baked at 375°F for 45 min. Used [oven] {+food:oven ?prov:used}. Generated [baked pie] {+food:baked ?prov:generated}.
|
|
26
|
+
|
|
27
|
+
We got the **Pie** {=food:pie}
|
|
28
|
+
|
|
29
|
+
The final pie was derived from [dough] {+food:dough ?prov:wasDerivedFrom} and [apple mix] {+food:mix ?prov:wasDerivedFrom}.
|
|
30
|
+
|
|
31
|
+
**Related**: Apple Crumble {+food:crumble !food:variation .food:Recipe}, Peach Pie {+food:peach !food:variation .food:Recipe}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[research] <https://research.example.org/>
|
|
2
|
+
[data] <https://research.example.org/datasets/>
|
|
3
|
+
|
|
4
|
+
# Machine Learning in Healthcare {=research:paper .prov:Entity label}
|
|
5
|
+
|
|
6
|
+
**Authors**: Dr. Sarah Martinez and Dr. James Liu, MIT CS Lab.
|
|
7
|
+
|
|
8
|
+
**Abstract**
|
|
9
|
+
|
|
10
|
+
This paper analyzes attention-based neural networks for medical imaging, citing prior work on deep learning in radiology.
|
|
11
|
+
|
|
12
|
+
**Methodology**
|
|
13
|
+
|
|
14
|
+
**Dataset** {=data:dataset .research:Dataset}
|
|
15
|
+
Source: GitHub medical imaging repository
|
|
16
|
+
Training: [80k] {+data:train ?research:detail .research:DatasetDetail} DICOM images, 15 classes
|
|
17
|
+
Validation: [10k] {+data:val ?research:detail .research:DatasetDetail} DICOM images
|
|
18
|
+
Test: [10k] {+data:test ?research:detail .research:DatasetDetail} DICOM images
|
|
19
|
+
|
|
20
|
+
**Kaggle Dataset** {=data:kaggle .research:Dataset} derived from primary dataset, featuring 512x512 grayscale images with patient metadata.
|
|
21
|
+
|
|
22
|
+
**Model Training** {=research:training .prov:Activity}
|
|
23
|
+
Duration: Feb 1-15, 2024
|
|
24
|
+
Association: Dr. James Liu as ML Engineer
|
|
25
|
+
Plan: Training protocol v2.0
|
|
26
|
+
Used: ML Dataset and Kaggle Dataset
|
|
27
|
+
Generated: [trained model] {+research:model ?prov:generated}
|
|
28
|
+
|
|
29
|
+
**Results**
|
|
30
|
+
|
|
31
|
+
Statistical significance: p < 0.05, sample size: [1000] {research:n ^^xsd:integer} patients.
|
|
32
|
+
|
|
33
|
+
**Accuracy Metrics** {=research:metrics .prov:Entity}
|
|
34
|
+
Training: [94.5%] {research:trainAcc}
|
|
35
|
+
Validation: [92.3%] {research:valAcc}
|
|
36
|
+
Test: [91.8%] {research:testAcc}
|
|
37
|
+
F1: [0.89] {research:f1 ^^xsd:decimal}
|
|
38
|
+
AUC-ROC: [0.93] {research:auc ^^xsd:decimal}
|
|
39
|
+
|
|
40
|
+
**SHACL Validation** {=research:shape .sh:NodeShape}
|
|
41
|
+
Target: Scientific Paper
|
|
42
|
+
Title: exactly 1 required
|
|
43
|
+
Author: at least 1 required
|
|
44
|
+
Citations: at least 1 required
|
|
45
|
+
|
|
46
|
+
**Funding**: NASA Space Medicine Research Initiative, grant NRA-2024-12345.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[nasa] <http://nasa.gov/>
|
|
2
|
+
|
|
3
|
+
# Apollo 11 Mission {=nasa:apollo11 .prov:Activity label}
|
|
4
|
+
|
|
5
|
+
## METADATA
|
|
6
|
+
|
|
7
|
+
Launch: [1969-07-16T13:32:00Z] {prov:startedAtTime ^^xsd:dateTime}
|
|
8
|
+
Landing: [1969-07-20T20:17:00Z] {nasa:landing ^^xsd:dateTime}
|
|
9
|
+
Duration (days): [8] {nasa:durationDays ^^xsd:integer}
|
|
10
|
+
Budget (B USD): [2.5] {nasa:budget ^^xsd:decimal}
|
|
11
|
+
Operator: [NASA] {+nasa:agency ?prov:wasAssociatedWith .prov:Organization}
|
|
12
|
+
|
|
13
|
+
## CREW
|
|
14
|
+
|
|
15
|
+
**Neil Armstrong** {+nasa:armstrong .prov:Person ?nasa:crew} - Commander, 1930
|
|
16
|
+
**Buzz Aldrin** {+nasa:aldrin .prov:Person ?nasa:crew} - LMP, 1930
|
|
17
|
+
**Michael Collins** {+nasa:collins .prov:Person ?nasa:crew} - CMP, 1930
|
|
18
|
+
|
|
19
|
+
## EQUIPMENT
|
|
20
|
+
|
|
21
|
+
**Saturn V** {+nasa:saturnv .nasa:Rocket ?nasa:equipment} - Boeing, 363ft
|
|
22
|
+
**LM Eagle** {+nasa:eagle .nasa:Module ?nasa:equipment} - Grumman
|
|
23
|
+
**CM Columbia** {+nasa:columbia .nasa:Module ?nasa:equipment} - NAA
|
|
24
|
+
|
|
25
|
+
## ACTIVITIES
|
|
26
|
+
|
|
27
|
+
**Launch** {+nasa:launch .prov:Activity} - Used Saturn V, generated orbit trajectory
|
|
28
|
+
|
|
29
|
+
**Lunar Landing** {+nasa:landing .prov:Activity} - Used LM Eagle, generated lunar presence and samples
|
|
30
|
+
|
|
31
|
+
**EVA** {+nasa:eva .prov:Activity} - 2h 18m, 250m, 21.5kg samples collected
|
|
32
|
+
|
|
33
|
+
## OBJECTIVES {=nasa:appollo11}
|
|
34
|
+
|
|
35
|
+
**Land on Moon** {+nasa:goal1 .nasa:Goal} - ACHIEVED 1969-07-20
|
|
36
|
+
**Return safely** {+nasa:goal2 .nasa:Goal} - ACHIEVED 1969-07-24
|
|
37
|
+
**Collect samples** {+nasa:goal3 .nasa:Goal} - ACHIEVED 21.5kg
|
|
38
|
+
|
|
39
|
+
## RELATIONSHIPS
|
|
40
|
+
|
|
41
|
+
Preceded by: [Apollo 10] {+nasa:apollo10 !nasa:precededBy .nasa:SpaceMission}, [Gemini 8] {+nasa:gemini8 !nasa:precededBy .nasa:SpaceMission}
|
|
42
|
+
|
|
43
|
+
Succeeded by: [Apollo 12] {+nasa:apollo12 ?nasa:succeededBy .nasa:SpaceMission}
|
|
44
|
+
|
|
45
|
+
**Delegation** {=nasa:delegation .prov:Delegation ?prov:qualifiedDelegation}
|
|
46
|
+
|
|
47
|
+
Delegate: [Mission Control] {+nasa:mcc ?prov:agent .prov:Organization}
|
|
48
|
+
Responsible: [NASA Admin] {+nasa:admin ?prov:agent .prov:Person}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
[mdld] <https://mdld.js.org/>
|
|
2
|
+
[xsd] <http://www.w3.org/2001/XMLSchema#>
|
|
3
|
+
[@vocab] <http://www.w3.org/2000/01/rdf-schema#>
|
|
4
|
+
[my] <tag:mdld@example.com,2026:>
|
|
5
|
+
[ex] <my:example:>
|
|
6
|
+
|
|
7
|
+
# MD-LD: Complete Syntax Specification {=mdld:dogfood .Class label}
|
|
8
|
+
|
|
9
|
+
> MD-LD is a **semantic annotation layer** for CommonMark Markdown that creates RDF knowledge graphs from explicit `{...}` annotations. {mdld:dogfood comment}
|
|
10
|
+
|
|
11
|
+
## Default Context {=mdld:default-context .Class label}
|
|
12
|
+
|
|
13
|
+
MD-LD provides these built-in prefixes and vocabulary:
|
|
14
|
+
|
|
15
|
+
Default vocabulary and prefixes: {mdld:includes .Class label}
|
|
16
|
+
- `@vocab`: `http://www.w3.org/2000/01/rdf-schema#` {=mdld:vocab}
|
|
17
|
+
- `rdf`: `http://www.w3.org/1999/02/22-rdf-syntax-ns#` {=mdld:rdf-prefix}
|
|
18
|
+
- `rdfs`: `http://www.w3.org/2000/01/rdf-schema#` {=mdld:rdfs-prefix}
|
|
19
|
+
- `xsd`: `http://www.w3.org/2001/XMLSchema#` {=mdld:xsd-prefix}
|
|
20
|
+
- `sh`: `http://www.w3.org/ns/shacl#` {=mdld:sh-prefix}
|
|
21
|
+
- `prov`: `http://www.w3.org/ns/prov#` {=mdld:prov-prefix}
|
|
22
|
+
|
|
23
|
+
## Prefix Folding {=mdld:prefix-folding .Container label}
|
|
24
|
+
|
|
25
|
+
MD-LD supports hierarchical namespace building through prefix folding:
|
|
26
|
+
|
|
27
|
+
Base namespace declaration:
|
|
28
|
+
- `[my] <tag:mdld@example.com,2026:>` {+mdld:base-namespace ?member}
|
|
29
|
+
|
|
30
|
+
Derived namespaces using CURIE syntax:
|
|
31
|
+
- `[ex] <my:example:>` {+mdld:derived-namespace ?member}
|
|
32
|
+
|
|
33
|
+
This resolves to: `tag:mdld@example.com,2026:example:`
|
|
34
|
+
|
|
35
|
+
**Resolution Rules:**
|
|
36
|
+
- Prefixes must be declared before they can be referenced (forward-reference only)
|
|
37
|
+
- Circular references are treated as literal strings
|
|
38
|
+
- Later declarations override earlier ones
|
|
39
|
+
|
|
40
|
+
**Examples:**
|
|
41
|
+
- `ex:doc` → `tag:mdld@example.com,2026:example:doc`
|
|
42
|
+
- `my:journal:2026-01-27` → `tag:mdld@example.com,2026:journal:2026-01-27`
|
|
43
|
+
|
|
44
|
+
### Prefix Folding Examples
|
|
45
|
+
Demonstrated namespaces:
|
|
46
|
+
- Document: [Example doc] {+ex:doc .Class label ?member}
|
|
47
|
+
- Feature: [Example feature] {+ex:feature .Class label ?member}
|
|
48
|
+
- Parser: [Example parser] {+ex:parser .Class label ?member}
|
|
49
|
+
|
|
50
|
+
## Angle-Bracket URLs {=mdld:angle-urls .Container label}
|
|
51
|
+
|
|
52
|
+
MD-LD supports angle-bracket URLs as value carriers with soft subject behavior:
|
|
53
|
+
|
|
54
|
+
### URL Value Carriers
|
|
55
|
+
External resources as soft subjects:
|
|
56
|
+
- <https://www.w3.org/TR/rdf11-concepts/> {.Specification label}
|
|
57
|
+
- <https://github.com/mdld-js/mdld-parse> {?mdld:implementation .Repository label}
|
|
58
|
+
- <https://arxiv.org/abs/2301.07041> {!mdld:cites .Paper label}
|
|
59
|
+
|
|
60
|
+
### URL Behavior Rules
|
|
61
|
+
Angle-bracket URLs follow these rules:
|
|
62
|
+
- Type declarations use URL as subject: `<URL> {.Type}`
|
|
63
|
+
- Object predicates use current subject: `<URL> {?predicate}`
|
|
64
|
+
- Reverse predicates use URL as subject: `<URL> {!predicate}`
|
|
65
|
+
- Literal predicates are ignored: `<URL> {literal}` (no output)
|
|
66
|
+
|
|
67
|
+
## Core Classes {=mdld:classes .Container label}
|
|
68
|
+
|
|
69
|
+
All classes used in this document:
|
|
70
|
+
|
|
71
|
+
- Document {+mdld:Document ?member .Class label}
|
|
72
|
+
- Concept {+mdld:Concept ?member .Class label}
|
|
73
|
+
- Resource {+mdld:Resource ?member .Class label}
|
|
74
|
+
- Principle {+mdld:Principle ?member .Class label}
|
|
75
|
+
- Feature {+mdld:Feature ?member .Class label}
|
|
76
|
+
- Layer {+mdld:Layer ?member .Class label}
|
|
77
|
+
- Component {+mdld:Component ?member .Class label}
|
|
78
|
+
- Software {+mdld:Software ?member .Class label}
|
|
79
|
+
|
|
80
|
+
## Parser Architecture {=mdld:parser-arch .Container label}
|
|
81
|
+
|
|
82
|
+
### Tokenization Phase
|
|
83
|
+
The parser processes documents in a single pass with these token types: {mdld:includes .Class label}
|
|
84
|
+
|
|
85
|
+
Token types created during scanning:
|
|
86
|
+
- `prefix` - Context declarations `[name] <IRI>`
|
|
87
|
+
- `heading` - Markdown headings `# text {attrs}`
|
|
88
|
+
- `list` - List items `- text {attrs}` or `1. text {attrs}`
|
|
89
|
+
- `blockquote` - Blockquotes `> text {attrs}`
|
|
90
|
+
- `code` - Code blocks with annotations
|
|
91
|
+
- `para` - Paragraphs with potential inline carriers
|
|
92
|
+
|
|
93
|
+
### Processing Pipeline
|
|
94
|
+
Document processing follows this pipeline:
|
|
95
|
+
1. **Line-by-line scanning** {+#line-by-line .Class label ?member}
|
|
96
|
+
2. **Context resolution** {+#context-resolution .Class label ?member}
|
|
97
|
+
3. **Subject tracking** {+#subject-tracking .Class label ?member}
|
|
98
|
+
4. **Annotation processing** {+#annotation-processing .Class label ?member}
|
|
99
|
+
5. **Quad emission** {+#quad-emission .Class label ?member}
|
|
100
|
+
|
|
101
|
+
### Semantic Block Processing
|
|
102
|
+
Annotations are parsed using cached semantic blocks: {mdld:includes .Class label}
|
|
103
|
+
- Parse `{...}` blocks into structured semantic objects
|
|
104
|
+
- Cache frequently used patterns for performance
|
|
105
|
+
- Extract subjects, predicates, types, and modifiers
|
|
106
|
+
- Handle all three predicate forms (`p`, `?p`, `!p`)
|
|
107
|
+
|
|
108
|
+
## Context Declarations {=mdld:context .Container label}
|
|
109
|
+
|
|
110
|
+
MD-LD supports prefix and vocabulary declarations following JSON-LD patterns:
|
|
111
|
+
|
|
112
|
+
Prefix declarations:
|
|
113
|
+
- `[mdld] <https://mdld.js.org/>` {+mdld:prefix .Class label ?member}
|
|
114
|
+
- `[xsd] <http://www.w3.org/2001/XMLSchema#>` {+mdld:xsd .Class label ?member}
|
|
115
|
+
- `[@vocab] <http://www.w3.org/2000/01/rdf-schema#>` {+mdld:vocab .Class label ?member}
|
|
116
|
+
|
|
117
|
+
## Core Principles {=mdld:principles .Container label}
|
|
118
|
+
|
|
119
|
+
MD-LD follows strict rules:
|
|
120
|
+
|
|
121
|
+
**Markdown-preserving** {+#markdown-preserving ?member label} - Remove `{...}` → valid Markdown
|
|
122
|
+
**Explicit only** {+#explicit-only ?member label} - No implicit semantics or guessing
|
|
123
|
+
**Single-pass** {+#single-pass ?member label} - Streaming-friendly processing
|
|
124
|
+
**Deterministic** {+#deterministic ?member label} - Same input → same output
|
|
125
|
+
**Traceable** {+#traceable ?member label} - Every fact traces to its source
|
|
126
|
+
|
|
127
|
+
## Subject Management {=mdld:subjects .Container label}
|
|
128
|
+
|
|
129
|
+
### Full IRI Subjects
|
|
130
|
+
[Document with full IRI] {+mdld:doc-full ?member .Class label} demonstrates persistent subjects
|
|
131
|
+
|
|
132
|
+
### Fragment Subjects
|
|
133
|
+
[Section with fragment] {+#fragment-example ?member .Class label} creates relative identifiers
|
|
134
|
+
|
|
135
|
+
### Subject Reset
|
|
136
|
+
[{=}] {+mdld:reset ?member label} shows subject clearing
|
|
137
|
+
|
|
138
|
+
### Temporary Objects
|
|
139
|
+
[Related concept] {+mdld:temporary ?member label} demonstrates block-scoped objects
|
|
140
|
+
|
|
141
|
+
### Soft Fragments
|
|
142
|
+
[Soft fragment example] {+#soft-fragment ?member label} demonstrates temporary fragments
|
|
143
|
+
|
|
144
|
+
**Use cases:**
|
|
145
|
+
- `[Related Item] {+ex:related ?schema:isRelatedTo}` - Links to a local fragment
|
|
146
|
+
- `[Parent] {+ex:parent !schema:hasPart}` - Reverse relationship
|
|
147
|
+
- `[Section] {+#section1 name ?hasPart}` - Object property with fragment
|
|
148
|
+
|
|
149
|
+
The soft IRI only exists within the current annotation block.
|
|
150
|
+
|
|
151
|
+
## Value Carriers {=mdld:carriers .Container label}
|
|
152
|
+
|
|
153
|
+
### Inline Elements
|
|
154
|
+
**Inline elements:** [*italic*] {+mdld:italic ?member} [**bold**] {+mdld:bold ?member} [`code`] {+mdld:code ?member}
|
|
155
|
+
|
|
156
|
+
### Block Elements
|
|
157
|
+
**Block elements:** # [Headings] {+mdld:heading ?member} > [Quotes] {+mdld:quote ?member}
|
|
158
|
+
|
|
159
|
+
### Links and Media
|
|
160
|
+
**Links:** [MD-LD Website](https://mdld.js.org) {?member}
|
|
161
|
+
**Images:**  {?member}
|
|
162
|
+
|
|
163
|
+
## Predicate Forms {=mdld:predicates .Class label}
|
|
164
|
+
|
|
165
|
+
Three predicate directions create different relationships:
|
|
166
|
+
|
|
167
|
+
- **Subject→Literal**: [MD-LD] {label} creates `mdld:doc label "MD-LD"`
|
|
168
|
+
- **Subject→Object**: [RDF](https://www.w3.org/RDF) {mdld:seeAlso} creates `mdld:doc rdfs:seeAlso <https://www.w3.org/RDF>`
|
|
169
|
+
- **Object→Subject**: [Example] {mdld:isDefinedBy} creates `mdld:example mdld:isDefinedBy mdld:doc`
|
|
170
|
+
|
|
171
|
+
## Type Declarations {=mdld:types .Container label}
|
|
172
|
+
|
|
173
|
+
### Single Types
|
|
174
|
+
[Single type example] {+mdld:single ?member .Class label}
|
|
175
|
+
|
|
176
|
+
### Multiple Types
|
|
177
|
+
[Multiple types example] {+mdld:multiple ?member .Class .mdld:Class1 label}
|
|
178
|
+
|
|
179
|
+
## Literal Modifiers {=mdld:literals .Container label}
|
|
180
|
+
|
|
181
|
+
### Typed Literals
|
|
182
|
+
[2024] {mdld:year ^^xsd:gYear}
|
|
183
|
+
[3.14159] {mdld:pi ^^xsd:decimal}
|
|
184
|
+
[true] {mdld:bool ^^xsd:boolean}
|
|
185
|
+
|
|
186
|
+
### Language-Tagged Literals
|
|
187
|
+
[Hello] {mdld:english @en}
|
|
188
|
+
[Bonjour] {mdld:french @fr}
|
|
189
|
+
[Hola] {mdld:spanish @es}
|
|
190
|
+
|
|
191
|
+
## Lists and Nesting {=mdld:lists .Container label}
|
|
192
|
+
|
|
193
|
+
Lists are pure Markdown structure with **no semantic scope**. Each list item requires explicit annotations.
|
|
194
|
+
|
|
195
|
+
### List Item Requirements
|
|
196
|
+
|
|
197
|
+
**Critical Rule**: All list items must have explicit subject (`{=iri}` or `{+iri}`) to emit semantics.
|
|
198
|
+
|
|
199
|
+
### Simple Lists
|
|
200
|
+
Research team members:
|
|
201
|
+
|
|
202
|
+
- **Principal investigator** {+#pi ?member .mdld:Role label}
|
|
203
|
+
- **Research assistant** {+#assistant ?member .mdld:Role label}
|
|
204
|
+
- **Lab technician** {+#tech ?member .mdld:Role label}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
## Code Blocks {=mdld:code-blocks .Container label}
|
|
208
|
+
|
|
209
|
+
### Annotated Code Blocks
|
|
210
|
+
```javascript {=mdld:example-code .Class text}
|
|
211
|
+
console.log("MD-LD creates RDF from Markdown");
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Parser Implementation Examples
|
|
215
|
+
```javascript {=mdld:parser-code .Class text}
|
|
216
|
+
// Token scanning implementation
|
|
217
|
+
function scanTokens(text) {
|
|
218
|
+
const tokens = [];
|
|
219
|
+
const lines = text.split('\n');
|
|
220
|
+
// Process each line for tokens...
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### EBNF Grammar Examples
|
|
225
|
+
```txt {=mdld:ebnf-grammar .Class text}
|
|
226
|
+
attrsBlock = "{" , whitespace* , attrsTokens? , whitespace* , "}" ;
|
|
227
|
+
attrsTokens = attrsToken , { whitespace+ , attrsToken } ;
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
This *JavaScript* {=mdld:js label} code shows annotation syntax.
|
|
231
|
+
|
|
232
|
+
## Blockquotes {=mdld:blockquote .Class label}
|
|
233
|
+
|
|
234
|
+
> Blockquotes serve as carriers for normative statements and comments. {mdld:blockquote comment}
|
|
235
|
+
|
|
236
|
+
> **Important**: All semantics must be explicit - no implicit inference. {mdld:normative comment}
|
|
237
|
+
|
|
238
|
+
> **Parser Note**: The implementation uses token-based scanning, not AST building. {mdld:parser-note comment}
|
|
239
|
+
|
|
240
|
+
## Advanced Features {=mdld:advanced .Class label}
|
|
241
|
+
|
|
242
|
+
### Soft Fragments
|
|
243
|
+
[Soft fragment example] {+#soft-fragment mdld:seeAlso label} demonstrates temporary fragments
|
|
244
|
+
|
|
245
|
+
### Complex Annotations
|
|
246
|
+
[Complex example] {=mdld:complex .Class label comment mdld:seeAlso} shows multiple predicates
|
|
247
|
+
|
|
248
|
+
### Reverse Relationships
|
|
249
|
+
[Target entity] {!mdld:hasPart label} demonstrates reverse predicate form
|
|
250
|
+
|
|
251
|
+
## Processing Model {=mdld:processing .Class label}
|
|
252
|
+
|
|
253
|
+
### Streaming Processing
|
|
254
|
+
MD-LD processes documents in a single pass: {?mdld:includes .Class label}
|
|
255
|
+
- Line-by-line tokenization {=#line-by-line}
|
|
256
|
+
- Subject tracking {=#subject-tracking}
|
|
257
|
+
- Quad emission {=#quad-emission}
|
|
258
|
+
|
|
259
|
+
### Origin Tracking
|
|
260
|
+
Every quad maintains origin information for round-trip serialization:
|
|
261
|
+
- Block identification
|
|
262
|
+
- Position tracking
|
|
263
|
+
- Slot indexing
|
|
264
|
+
|
|
265
|
+
### Semantic Block Caching
|
|
266
|
+
The parser uses caching for performance: {mdld:includes .Class label}
|
|
267
|
+
- Parse semantic blocks once and cache results
|
|
268
|
+
- Avoid repeated parsing of identical annotations
|
|
269
|
+
- Maintain deterministic output while improving speed
|
|
270
|
+
|
|
271
|
+
## Error Handling {=mdld:errors .Class label}
|
|
272
|
+
|
|
273
|
+
### Graceful Degradation
|
|
274
|
+
MD-LD recovers from malformed annotations:
|
|
275
|
+
- Unknown prefixes → skip annotation
|
|
276
|
+
- Malformed IRIs → skip annotation
|
|
277
|
+
- Unbalanced braces → fatal error
|
|
278
|
+
- Invalid carriers → skip annotation
|
|
279
|
+
|
|
280
|
+
## Connected Knowledge Graph {=mdld:graph .Class label}
|
|
281
|
+
|
|
282
|
+
This document demonstrates how MD-LD creates a **self-describing knowledge graph** where:
|
|
283
|
+
- The document explains MD-LD using MD-LD
|
|
284
|
+
- Every concept is explicitly typed and related
|
|
285
|
+
- The resulting RDF graph mirrors the document structure
|
|
286
|
+
- All features connect into a coherent semantic model
|
|
287
|
+
|
|
288
|
+
> The document itself becomes both specification and proof of concept. { comment}
|