mdld-parse 0.5.1 → 0.5.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/package.json +1 -1
- package/src/parse.js +9 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdld-parse",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "A standards-compliant parser for **MD-LD (Markdown-Linked Data)** — a human-friendly RDF authoring format that extends Markdown with semantic annotations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
package/src/parse.js
CHANGED
|
@@ -400,10 +400,8 @@ function processTypeAnnotations(sem, newSubject, localObject, carrierO, S, block
|
|
|
400
400
|
sem.types.forEach(t => {
|
|
401
401
|
const typeIRI = typeof t === 'string' ? t : t.iri;
|
|
402
402
|
const entryIndex = typeof t === 'string' ? null : t.entryIndex;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
typeSubject = carrierO;
|
|
406
|
-
}
|
|
403
|
+
// Type subject priority: explicit subject > soft object > URL > current subject
|
|
404
|
+
let typeSubject = newSubject || localObject || carrierO || S;
|
|
407
405
|
createTypeQuad(typeIRI, typeSubject, state, block.id, entryIndex);
|
|
408
406
|
});
|
|
409
407
|
}
|
|
@@ -414,12 +412,16 @@ const determinePredicateRole = (pred, carrier, newSubject, previousSubject, loca
|
|
|
414
412
|
}
|
|
415
413
|
switch (pred.form) {
|
|
416
414
|
case '':
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
:
|
|
415
|
+
// Literal predicates: explicit subject > current subject, URL only when no explicit subject
|
|
416
|
+
return newSubject ? { subject: localObject || S, object: L }
|
|
417
|
+
: (carrier?.type === 'link' && carrier?.url && carrier.text !== carrier.url)
|
|
418
|
+
? { subject: newSubjectOrCarrierO, object: L }
|
|
419
|
+
: { subject: localObject || S, object: L };
|
|
420
420
|
case '?':
|
|
421
|
+
// Object predicates: use current subject → explicit object or URL
|
|
421
422
|
return { subject: newSubject ? previousSubject : S, object: localObject || newSubjectOrCarrierO };
|
|
422
423
|
case '!':
|
|
424
|
+
// Reverse predicates: explicit object or URL → current subject
|
|
423
425
|
return { subject: localObject || newSubjectOrCarrierO, object: newSubject ? previousSubject : S };
|
|
424
426
|
default:
|
|
425
427
|
return null;
|