mdld-parse 0.8.1 → 0.8.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdld-parse",
3
- "version": "0.8.1",
3
+ "version": "0.8.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/generate.js CHANGED
@@ -46,7 +46,7 @@ export function generate(quads, context = {}, primarySubject = null) {
46
46
 
47
47
  const { text } = buildDeterministicMDLD(subjectGroups, fullContext, primarySubject);
48
48
 
49
- return text;
49
+ return { text, context: fullContext };
50
50
  }
51
51
 
52
52
  function normalizeAndSortQuads(quads) {
package/src/utils.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { URL_REGEX, DEFAULT_CONTEXT } from './constants.js';
2
2
 
3
+ const VALID_URI_SCHEMES = /^(https?|ftp|mailto|tag|nih|urn|uuid|did|web|ipfs|ipns|data|file):/;
4
+
3
5
  // Base Term class for RDF/JS compatibility
4
6
  export class Term {
5
7
  constructor(id) {
@@ -268,7 +270,7 @@ export function expandIRI(term, ctx) {
268
270
  }
269
271
 
270
272
  export function shortenIRI(iri, ctx) {
271
- if (!iri || !iri.startsWith('http')) return iri;
273
+ if (!iri || !VALID_URI_SCHEMES.test(iri)) return iri;
272
274
  if (ctx['@vocab'] && iri.startsWith(ctx['@vocab'])) return iri.substring(ctx['@vocab'].length);
273
275
 
274
276
  // Find the best matching prefix - more precise matching