mdld-parse 0.9.3 → 0.9.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 +4 -3
- package/dist/README.md +4 -3
- package/dist/docs/API.md +3 -1
- package/dist/docs/Guide.md +660 -166
- package/dist/docs/LiterateRDF.md +472 -0
- package/dist/docs/Nostr.md +544 -0
- package/dist/docs/Parser.md +57 -1
- package/dist/docs/guide-m.md +56 -0
- package/dist/docs/one-page.md +322 -0
- package/dist/docs/primary-subject.md +64 -13
- package/dist/examples/Status-SHACL.md +8 -10
- package/dist/examples/demo/journal.md +110 -9
- package/dist/examples/demo/minimal.md +18 -6
- package/dist/examples/demo/project.md +90 -7
- package/dist/examples/demo/prov.md +107 -0
- package/dist/examples/demo/rdf.md +69 -0
- package/dist/examples/demo/recipe.md +79 -15
- package/dist/examples/demo/research.md +110 -30
- package/dist/examples/demo/shacl.md +161 -0
- package/dist/examples/demo/space-mission.md +109 -28
- package/dist/examples/demo/tasks.md +175 -0
- package/dist/examples/demo/xsd.md +91 -0
- package/dist/index.html +686 -260
- package/dist/index.js +474 -248
- package/dist/spec/Spec-compact.md +13 -8
- package/dist/spec/Spec-ultra.md +14 -3
- package/dist/spec/Spec.md +68 -20
- package/package.json +2 -2
- package/dist/examples/prov-o.md +0 -2367
- package/dist/examples/rdf.md +0 -827
- package/dist/examples/shacl.md +0 -3399
package/dist/index.js
CHANGED
|
@@ -116,7 +116,7 @@ var e = {
|
|
|
116
116
|
};
|
|
117
117
|
function f(e, t) {
|
|
118
118
|
if (!e || !t || !t.quadIndex) return null;
|
|
119
|
-
let n =
|
|
119
|
+
let n = te(e);
|
|
120
120
|
return n && t.quadIndex.get(n) || null;
|
|
121
121
|
}
|
|
122
122
|
function p(e) {
|
|
@@ -295,15 +295,15 @@ function v(e, t, n) {
|
|
|
295
295
|
r
|
|
296
296
|
]);
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function te(e) {
|
|
299
299
|
return e ? v(e.subject, e.predicate, e.object) : null;
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function ne(e, t, n, r, i) {
|
|
302
302
|
return t ? i.literal(e, i.namedNode(h(t, r))) : n ? i.literal(e, n) : i.literal(e);
|
|
303
303
|
}
|
|
304
304
|
//#endregion
|
|
305
305
|
//#region src/tokenizers.js
|
|
306
|
-
function
|
|
306
|
+
function re(e) {
|
|
307
307
|
if (e.length < 3) return null;
|
|
308
308
|
let t = e[0];
|
|
309
309
|
if (t !== "`" && t !== "~") return null;
|
|
@@ -319,7 +319,7 @@ function b(e) {
|
|
|
319
319
|
infoString: r
|
|
320
320
|
};
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function ie(e) {
|
|
323
323
|
if (e[0] !== "[") return null;
|
|
324
324
|
let t = e.indexOf("]", 1);
|
|
325
325
|
if (t === -1) return null;
|
|
@@ -336,7 +336,7 @@ function x(e) {
|
|
|
336
336
|
iri: a
|
|
337
337
|
} : null;
|
|
338
338
|
}
|
|
339
|
-
function
|
|
339
|
+
function ae(e) {
|
|
340
340
|
if (e[0] !== "#") return null;
|
|
341
341
|
let t = 1;
|
|
342
342
|
for (; t < e.length && t < 6 && e[t] === "#";) t++;
|
|
@@ -350,7 +350,7 @@ function S(e) {
|
|
|
350
350
|
attrs: o
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function y(e) {
|
|
354
354
|
let t = 0;
|
|
355
355
|
for (; t < e.length && (e[t] === " " || e[t] === " ");) t++;
|
|
356
356
|
let n = t;
|
|
@@ -373,7 +373,7 @@ function C(e) {
|
|
|
373
373
|
attrs: s
|
|
374
374
|
};
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function oe(e) {
|
|
377
377
|
if (e[0] !== ">" || e.length > 1 && e[1] !== " " && e[1] !== " ") return null;
|
|
378
378
|
let t = 1;
|
|
379
379
|
for (; t < e.length && (e[t] === " " || e[t] === " ");) t++;
|
|
@@ -383,7 +383,7 @@ function w(e) {
|
|
|
383
383
|
attrs: r
|
|
384
384
|
};
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function se(e) {
|
|
387
387
|
let t = 0;
|
|
388
388
|
for (; t < e.length && (e[t] === " " || e[t] === " ");) t++;
|
|
389
389
|
if (t >= e.length || e[t] !== "{" || (t++, t >= e.length || e[t] !== "=")) return null;
|
|
@@ -395,12 +395,12 @@ function T(e) {
|
|
|
395
395
|
for (t++; t < e.length && (e[t] === " " || e[t] === " ");) t++;
|
|
396
396
|
return t < e.length ? null : { content: i };
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function ce(e, t, n = "[", r = "]") {
|
|
399
399
|
let i = 1, a = t + 1;
|
|
400
400
|
for (; a < e.length && i > 0;) e[a] === n && i++, e[a] === r && i--, i > 0 && a++;
|
|
401
401
|
return i === 0 ? a : null;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function b(e, t) {
|
|
404
404
|
let n = t;
|
|
405
405
|
for (; n < e.length && (e[n] === " " || e[n] === " ");) n++;
|
|
406
406
|
if (n >= e.length || e[n] !== "{") return null;
|
|
@@ -410,7 +410,7 @@ function E(e, t) {
|
|
|
410
410
|
endPos: r + 1
|
|
411
411
|
};
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function le(e, t) {
|
|
414
414
|
if (e[t] !== "<") return null;
|
|
415
415
|
let n = e.indexOf(">", t + 1);
|
|
416
416
|
if (n === -1) return null;
|
|
@@ -420,7 +420,7 @@ function re(e, t) {
|
|
|
420
420
|
endPos: n + 1
|
|
421
421
|
} : null;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function ue(e, t) {
|
|
424
424
|
let n = e[t];
|
|
425
425
|
if (n !== "*" && n !== "_") return null;
|
|
426
426
|
let r = 1;
|
|
@@ -433,7 +433,7 @@ function ie(e, t) {
|
|
|
433
433
|
s++;
|
|
434
434
|
continue;
|
|
435
435
|
}
|
|
436
|
-
let t = e.slice(o, s), a = s + r, c =
|
|
436
|
+
let t = e.slice(o, s), a = s + r, c = b(e, a), l = c ? c.endPos : a;
|
|
437
437
|
return {
|
|
438
438
|
type: i,
|
|
439
439
|
content: t,
|
|
@@ -446,7 +446,7 @@ function ie(e, t) {
|
|
|
446
446
|
}
|
|
447
447
|
return null;
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function de(e, t) {
|
|
450
450
|
if (e[t] !== "`") return null;
|
|
451
451
|
let n = 1;
|
|
452
452
|
for (; t + n < e.length && e[t + n] === "`";) n++;
|
|
@@ -454,7 +454,7 @@ function ae(e, t) {
|
|
|
454
454
|
let r = "`".repeat(n), i = t + n, a = i;
|
|
455
455
|
for (; a < e.length;) {
|
|
456
456
|
if (e.slice(a, a + n) === r) {
|
|
457
|
-
let t = e.slice(i, a), r = a + n, o =
|
|
457
|
+
let t = e.slice(i, a), r = a + n, o = b(e, r), s = o ? o.endPos : r;
|
|
458
458
|
return {
|
|
459
459
|
type: "code",
|
|
460
460
|
content: t,
|
|
@@ -467,9 +467,9 @@ function ae(e, t) {
|
|
|
467
467
|
}
|
|
468
468
|
return null;
|
|
469
469
|
}
|
|
470
|
-
function
|
|
470
|
+
function fe(e, t) {
|
|
471
471
|
if (e[t] !== "[") return null;
|
|
472
|
-
let n =
|
|
472
|
+
let n = ce(e, t, "[", "]");
|
|
473
473
|
if (!n) return null;
|
|
474
474
|
let r = e.slice(t + 1, n), i = n + 1, a = null;
|
|
475
475
|
if (i < e.length && e[i] === "(") {
|
|
@@ -482,7 +482,7 @@ function oe(e, t) {
|
|
|
482
482
|
n.match(/^[a-zA-Z][a-zA-Z0-9+\-.]*:/) && (a = n, i = t + 1);
|
|
483
483
|
}
|
|
484
484
|
}
|
|
485
|
-
let o =
|
|
485
|
+
let o = b(e, i), s = o ? o.endPos : i;
|
|
486
486
|
return {
|
|
487
487
|
type: a ? "link" : "span",
|
|
488
488
|
text: r,
|
|
@@ -492,26 +492,26 @@ function oe(e, t) {
|
|
|
492
492
|
bracketEnd: n + 1
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
|
-
function
|
|
495
|
+
function x(e, t = 0) {
|
|
496
496
|
let n = [], r = e.length, i = 0;
|
|
497
497
|
for (; i < r;) {
|
|
498
498
|
let r = e[i], a = null;
|
|
499
499
|
switch (r) {
|
|
500
500
|
case "<":
|
|
501
|
-
if (a =
|
|
502
|
-
let t =
|
|
501
|
+
if (a = le(e, i), a) {
|
|
502
|
+
let t = b(e, a.endPos);
|
|
503
503
|
t && (a.attrs = t.attrs, a.endPos = t.endPos), a.type = "link", a.text = a.url;
|
|
504
504
|
}
|
|
505
505
|
break;
|
|
506
506
|
case "[":
|
|
507
|
-
a =
|
|
507
|
+
a = fe(e, i);
|
|
508
508
|
break;
|
|
509
509
|
case "*":
|
|
510
510
|
case "_":
|
|
511
|
-
a =
|
|
511
|
+
a = ue(e, i);
|
|
512
512
|
break;
|
|
513
513
|
case "`":
|
|
514
|
-
a =
|
|
514
|
+
a = de(e, i);
|
|
515
515
|
break;
|
|
516
516
|
}
|
|
517
517
|
if (!a) {
|
|
@@ -538,23 +538,23 @@ function se(e, t = 0) {
|
|
|
538
538
|
}
|
|
539
539
|
//#endregion
|
|
540
540
|
//#region src/shared.js
|
|
541
|
-
var
|
|
542
|
-
function
|
|
543
|
-
return
|
|
541
|
+
var S = /* @__PURE__ */ new Map();
|
|
542
|
+
function pe(e) {
|
|
543
|
+
return S.has(e) || S.set(e, RegExp(`^(${e}{3,})`)), S.get(e);
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function C(e, t, n, r, i) {
|
|
546
546
|
let a = r + (r < e.length && e[r] === " " ? 1 : e.slice(r).match(/^\s+/)?.[0]?.length || 0);
|
|
547
547
|
return {
|
|
548
548
|
valueRange: [n + a, n + a + i],
|
|
549
|
-
attrsRange:
|
|
549
|
+
attrsRange: w(e, t, n)
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
function
|
|
552
|
+
function w(e, t, n) {
|
|
553
553
|
if (!t) return null;
|
|
554
554
|
let r = e.lastIndexOf(t);
|
|
555
555
|
return r >= 0 ? [n + r, n + r + t.length] : null;
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function T(e, t, n, r = null, i = null, a = null, o = {}) {
|
|
558
558
|
let s = {
|
|
559
559
|
type: e,
|
|
560
560
|
range: t,
|
|
@@ -570,31 +570,31 @@ function A(e, t, n, r = null, i = null, a = null, o = {}) {
|
|
|
570
570
|
value: null
|
|
571
571
|
}), s;
|
|
572
572
|
}
|
|
573
|
-
function
|
|
574
|
-
let a = i[4] || null, o =
|
|
575
|
-
return
|
|
573
|
+
function me(e, t, n, r, i) {
|
|
574
|
+
let a = i[4] || null, o = C(t, a, n, i[1].length + (i[2] ? i[2].length : 0), i[3].length);
|
|
575
|
+
return T(e, [n, r - 1], i[3].trim(), a, o.attrsRange, o.valueRange, { indent: i[1].length });
|
|
576
576
|
}
|
|
577
|
-
var
|
|
577
|
+
var E = {}, he = Object.freeze({
|
|
578
578
|
predicates: [],
|
|
579
579
|
types: [],
|
|
580
580
|
subject: null
|
|
581
581
|
});
|
|
582
|
-
function
|
|
583
|
-
if (!e) return
|
|
584
|
-
let t =
|
|
585
|
-
return t || (t = Object.freeze(_(e)),
|
|
582
|
+
function D(e) {
|
|
583
|
+
if (!e) return he;
|
|
584
|
+
let t = E[e];
|
|
585
|
+
return t || (t = Object.freeze(_(e)), E[e] = t), t;
|
|
586
586
|
}
|
|
587
|
-
function
|
|
587
|
+
function ge(e, t) {
|
|
588
588
|
if (!e.range || !t) return 0;
|
|
589
589
|
let n = t.substring(e.range.start, e.range.end).match(/^(\s*)/), r = n ? n[1].length : 0;
|
|
590
590
|
return Math.floor(r / 2);
|
|
591
591
|
}
|
|
592
|
-
function
|
|
592
|
+
function _e(e, t, n = null) {
|
|
593
593
|
if (!t || !e) return "";
|
|
594
594
|
let r = e.substring(t[0], t[1]);
|
|
595
595
|
return n && (r = r.substring(0, n[0] - t[0]) + r.substring(n[1] - t[0])), r.trim();
|
|
596
596
|
}
|
|
597
|
-
function
|
|
597
|
+
function ve(e) {
|
|
598
598
|
if (!e.text) return "";
|
|
599
599
|
let t = e.text;
|
|
600
600
|
e.attrsRange && (t = t.substring(0, e.attrsRange[0] - (e.range?.[0] || 0)) + t.substring(e.attrsRange[1] - (e.range?.[0] || 0)));
|
|
@@ -607,7 +607,7 @@ function pe(e) {
|
|
|
607
607
|
default: return t.trim();
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
|
-
function
|
|
610
|
+
function ye(e, t, n, r = null) {
|
|
611
611
|
return {
|
|
612
612
|
blockId: e.id,
|
|
613
613
|
range: e.range,
|
|
@@ -619,72 +619,72 @@ function me(e, t, n, r = null) {
|
|
|
619
619
|
value: e.text || ""
|
|
620
620
|
};
|
|
621
621
|
}
|
|
622
|
-
function
|
|
622
|
+
function O(e, t, n) {
|
|
623
623
|
if (!t) return null;
|
|
624
624
|
let r = t.value, i = r.indexOf("#"), a = i > -1 ? r.slice(0, i) : r;
|
|
625
625
|
return n.namedNode(a + "#" + e);
|
|
626
626
|
}
|
|
627
|
-
function
|
|
628
|
-
return e.subject ? e.subject === "RESET" ? (t.currentSubject = null, null) : e.subject.startsWith("=#") ?
|
|
627
|
+
function k(e, t) {
|
|
628
|
+
return e.subject ? e.subject === "RESET" ? (t.currentSubject = null, null) : e.subject.startsWith("=#") ? O(e.subject.substring(2), t.currentSubject, t.df) : t.df.namedNode(h(e.subject, t.ctx)) : null;
|
|
629
629
|
}
|
|
630
|
-
function
|
|
631
|
-
return e.object ? e.object.startsWith("#") ?
|
|
630
|
+
function be(e, t) {
|
|
631
|
+
return e.object ? e.object.startsWith("#") ? O(e.object.substring(1), t.currentSubject, t.df) : t.df.namedNode(h(e.object, t.ctx)) : null;
|
|
632
632
|
}
|
|
633
|
-
function
|
|
633
|
+
function A(e) {
|
|
634
634
|
return e ? e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'") : "";
|
|
635
635
|
}
|
|
636
|
-
function
|
|
636
|
+
function j(e) {
|
|
637
637
|
return e?.termType === "Literal";
|
|
638
638
|
}
|
|
639
|
-
function
|
|
639
|
+
function M(e) {
|
|
640
640
|
return e?.termType === "NamedNode";
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function xe(e) {
|
|
643
643
|
return e?.value === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function N(e, t) {
|
|
646
646
|
if (!e) return null;
|
|
647
647
|
let n = g(e, t);
|
|
648
648
|
return n.includes(":") ? n.split(":")[0] : null;
|
|
649
649
|
}
|
|
650
|
-
function
|
|
650
|
+
function Se(e, t) {
|
|
651
651
|
let n = /* @__PURE__ */ new Set();
|
|
652
652
|
for (let r of e.values()) for (let e of r) {
|
|
653
|
-
let r =
|
|
653
|
+
let r = N(e.subject.value, t);
|
|
654
654
|
r && n.add(r);
|
|
655
|
-
let i =
|
|
656
|
-
if (i && n.add(i),
|
|
657
|
-
let r =
|
|
655
|
+
let i = N(e.predicate.value, t);
|
|
656
|
+
if (i && n.add(i), M(e.object)) {
|
|
657
|
+
let r = N(e.object.value, t);
|
|
658
658
|
r && n.add(r);
|
|
659
659
|
}
|
|
660
660
|
if (e.object.datatype && e.object.datatype.value) {
|
|
661
|
-
let r =
|
|
661
|
+
let r = N(e.object.datatype.value, t);
|
|
662
662
|
r && n.add(r);
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
return n;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function P(e, t, n, r, i = []) {
|
|
668
668
|
let a = r(e, t);
|
|
669
669
|
t.currentBlock = a, t.blockStack.push(a.id), i.forEach((n) => n(e, t)), n(e, t, e.type), t.blockStack.pop(), t.currentBlock = t.blockStack.length > 0 ? t.origin.blocks.get(t.blockStack[t.blockStack.length - 1]) : null;
|
|
670
670
|
}
|
|
671
|
-
function
|
|
671
|
+
function F(e) {
|
|
672
672
|
return e.sort((e, t) => e.predicate.value.localeCompare(t.predicate.value));
|
|
673
673
|
}
|
|
674
|
-
var
|
|
675
|
-
function
|
|
674
|
+
var Ce = (e, t) => `[${e}] <${t}>\n`;
|
|
675
|
+
function we(e, t) {
|
|
676
676
|
let n = g(e.predicate.value, t);
|
|
677
677
|
e.object.language ? n += ` @${e.object.language}` : e.object.datatype.value !== "http://www.w3.org/2001/XMLSchema#string" && (n += ` ^^${g(e.object.datatype.value, t)}`);
|
|
678
678
|
let r = e.object.value || e.object, i = typeof r == "string" ? r : String(r), a = e.object.datatype?.value || "";
|
|
679
679
|
return i.includes("\n") ? `~~~ {${n}}\n${i}\n~~~\n\n` : a.includes("integer") || a.includes("decimal") || a.includes("double") || a.includes("float") ? `\`${i}\` {${n}}\n` : a.includes("date") || a.includes("time") ? `*${i}* {${n}}\n` : a.includes("boolean") ? `**${i}** {${n}}\n` : `[${i}] {${n}}\n`;
|
|
680
680
|
}
|
|
681
|
-
var
|
|
681
|
+
var Te = (e, t, n = null) => {
|
|
682
682
|
let r = g(e.object.value, t), i = g(e.predicate.value, t);
|
|
683
683
|
return `[${n && n.has(e.object.value) ? n.get(e.object.value) : r}] {+${r} ?${i}}\n`;
|
|
684
684
|
};
|
|
685
|
-
function
|
|
685
|
+
function Ee(e) {
|
|
686
686
|
let t = [], n = [], r = [];
|
|
687
|
-
for (let i of e)
|
|
687
|
+
for (let i of e) xe(i.predicate) ? t.push(i) : j(i.object) ? n.push(i) : M(i.object) && r.push(i);
|
|
688
688
|
return {
|
|
689
689
|
types: t,
|
|
690
690
|
literals: n,
|
|
@@ -693,7 +693,7 @@ function xe(e) {
|
|
|
693
693
|
}
|
|
694
694
|
//#endregion
|
|
695
695
|
//#region src/parse.js
|
|
696
|
-
function
|
|
696
|
+
function I(t, n = {}) {
|
|
697
697
|
let r = typeof t == "object" && !!t && "text" in t, i = r ? t.text : t, a = r ? {
|
|
698
698
|
context: t.context,
|
|
699
699
|
dataFactory: t.dataFactory,
|
|
@@ -715,13 +715,15 @@ function V(t, n = {}) {
|
|
|
715
715
|
},
|
|
716
716
|
currentSubject: null,
|
|
717
717
|
primarySubject: null,
|
|
718
|
+
primaryType: null,
|
|
719
|
+
primaryLabel: null,
|
|
718
720
|
tokens: null,
|
|
719
721
|
currentTokenIndex: -1,
|
|
720
722
|
statements: [],
|
|
721
723
|
statementCandidates: /* @__PURE__ */ new Map(),
|
|
722
724
|
currentBlock: null,
|
|
723
725
|
blockStack: []
|
|
724
|
-
}, s =
|
|
726
|
+
}, s = De(i);
|
|
725
727
|
o.tokens = s.tokens;
|
|
726
728
|
for (let e = 0; e < o.tokens.length; e++) {
|
|
727
729
|
let t = o.tokens[e];
|
|
@@ -734,7 +736,7 @@ function V(t, n = {}) {
|
|
|
734
736
|
o.ctx[t.prefix] = e;
|
|
735
737
|
continue;
|
|
736
738
|
}
|
|
737
|
-
|
|
739
|
+
Le[t.type]?.(t, o);
|
|
738
740
|
}
|
|
739
741
|
let c = /* @__PURE__ */ new Set();
|
|
740
742
|
for (let e of o.quads) c.add(v(e.subject, e.predicate, e.object));
|
|
@@ -750,17 +752,19 @@ function V(t, n = {}) {
|
|
|
750
752
|
origin: o.origin,
|
|
751
753
|
context: o.ctx,
|
|
752
754
|
primarySubject: o.primarySubject,
|
|
755
|
+
primaryType: o.primaryType,
|
|
756
|
+
primaryLabel: o.primaryLabel,
|
|
753
757
|
md: s.md
|
|
754
758
|
};
|
|
755
759
|
}
|
|
756
|
-
function
|
|
757
|
-
return e.type === "code" ? [] : e._carriers || (e._carriers =
|
|
760
|
+
function L(e) {
|
|
761
|
+
return e.type === "code" ? [] : e._carriers || (e._carriers = Oe(e.text, e.range[0]));
|
|
758
762
|
}
|
|
759
|
-
function
|
|
763
|
+
function De(e) {
|
|
760
764
|
let t = [], n = [], r = e.split("\n"), i = 0, a = null, o = [
|
|
761
765
|
{
|
|
762
766
|
type: "fence",
|
|
763
|
-
test: (e) =>
|
|
767
|
+
test: (e) => re(e.trim()),
|
|
764
768
|
process: s
|
|
765
769
|
},
|
|
766
770
|
{
|
|
@@ -770,27 +774,27 @@ function Se(e) {
|
|
|
770
774
|
},
|
|
771
775
|
{
|
|
772
776
|
type: "prefix",
|
|
773
|
-
test: (e) =>
|
|
777
|
+
test: (e) => ie(e),
|
|
774
778
|
process: c
|
|
775
779
|
},
|
|
776
780
|
{
|
|
777
781
|
type: "standalone",
|
|
778
|
-
test: (e) =>
|
|
782
|
+
test: (e) => se(e),
|
|
779
783
|
process: p
|
|
780
784
|
},
|
|
781
785
|
{
|
|
782
786
|
type: "heading",
|
|
783
|
-
test: (e) =>
|
|
787
|
+
test: (e) => ae(e),
|
|
784
788
|
process: l
|
|
785
789
|
},
|
|
786
790
|
{
|
|
787
791
|
type: "list",
|
|
788
|
-
test: (e) =>
|
|
792
|
+
test: (e) => y(e),
|
|
789
793
|
process: u
|
|
790
794
|
},
|
|
791
795
|
{
|
|
792
796
|
type: "blockquote",
|
|
793
|
-
test: (e) =>
|
|
797
|
+
test: (e) => oe(e),
|
|
794
798
|
process: d
|
|
795
799
|
},
|
|
796
800
|
{
|
|
@@ -802,7 +806,7 @@ function Se(e) {
|
|
|
802
806
|
function s(e, r, i) {
|
|
803
807
|
let o = e.trim();
|
|
804
808
|
if (a) {
|
|
805
|
-
let i = a.fence[0], s = i.repeat(a.fence.length), c = o.match(
|
|
809
|
+
let i = a.fence[0], s = i.repeat(a.fence.length), c = o.match(pe(i));
|
|
806
810
|
if (c && c[1] === s) {
|
|
807
811
|
let i = a.valueRangeStart, o = Math.max(i, r - 1);
|
|
808
812
|
t.push({
|
|
@@ -820,7 +824,7 @@ function Se(e) {
|
|
|
820
824
|
n.push(s);
|
|
821
825
|
}
|
|
822
826
|
} else {
|
|
823
|
-
let t =
|
|
827
|
+
let t = re(o);
|
|
824
828
|
if (!t) return !1;
|
|
825
829
|
let i = t.attrs, s = i ? e.indexOf(i) : -1, c = r + e.length + 1;
|
|
826
830
|
a = {
|
|
@@ -838,7 +842,7 @@ function Se(e) {
|
|
|
838
842
|
return !0;
|
|
839
843
|
}
|
|
840
844
|
function c(e, n, r) {
|
|
841
|
-
let i =
|
|
845
|
+
let i = ie(e);
|
|
842
846
|
return t.push({
|
|
843
847
|
type: "prefix",
|
|
844
848
|
prefix: i.prefix,
|
|
@@ -846,32 +850,32 @@ function Se(e) {
|
|
|
846
850
|
}), !0;
|
|
847
851
|
}
|
|
848
852
|
function l(e, r, i) {
|
|
849
|
-
let a =
|
|
850
|
-
t.push(
|
|
853
|
+
let a = ae(e), o = a.attrs, s = a.depth, c = C(e, o, r, s, a.content.length);
|
|
854
|
+
t.push(T("heading", [r, i - 1], a.content, o, c.attrsRange, c.valueRange, { depth: a.depth }));
|
|
851
855
|
let l = `${"#".repeat(a.depth)} ${a.content}`;
|
|
852
856
|
return n.push(l), !0;
|
|
853
857
|
}
|
|
854
858
|
function u(e, r, i) {
|
|
855
|
-
let a =
|
|
859
|
+
let a = y(e), o = " ".repeat(a.indent), s = [
|
|
856
860
|
e,
|
|
857
861
|
o,
|
|
858
862
|
a.marker,
|
|
859
863
|
a.content,
|
|
860
864
|
a.attrs
|
|
861
865
|
];
|
|
862
|
-
t.push(
|
|
866
|
+
t.push(me("list", e, r, i, s));
|
|
863
867
|
let c = `${o}${a.marker} ${a.content}`;
|
|
864
868
|
return n.push(c), !0;
|
|
865
869
|
}
|
|
866
870
|
function d(e, r, i) {
|
|
867
|
-
let a =
|
|
868
|
-
t.push(
|
|
871
|
+
let a = oe(e), o = a.attrs, s = e.startsWith("> ") ? 2 : e.indexOf(">") + 1, c = s + a.content.length;
|
|
872
|
+
t.push(T("blockquote", [r, i - 1], a.content, o, w(e, o, r), [r + s, r + c]));
|
|
869
873
|
let l = `> ${a.content}`;
|
|
870
874
|
return n.push(l), !0;
|
|
871
875
|
}
|
|
872
876
|
function f(e, r, i) {
|
|
873
|
-
t.push(
|
|
874
|
-
let a = e, o =
|
|
877
|
+
t.push(T("para", [r, i - 1], e.trim()));
|
|
878
|
+
let a = e, o = x(a, 0);
|
|
875
879
|
for (let e of o) if (e.attrs && (e.type === "emphasis" || e.type === "code")) {
|
|
876
880
|
let t = a.substring(0, e.range[0]), n = a.substring(e.range[1]);
|
|
877
881
|
a = t + (e.text || "") + n;
|
|
@@ -895,13 +899,13 @@ function Se(e) {
|
|
|
895
899
|
md: n.join("\n")
|
|
896
900
|
};
|
|
897
901
|
}
|
|
898
|
-
function
|
|
899
|
-
return
|
|
902
|
+
function Oe(e, t = 0) {
|
|
903
|
+
return x(e, t);
|
|
900
904
|
}
|
|
901
|
-
function
|
|
905
|
+
function R(e, t) {
|
|
902
906
|
let n = e._blockId || p(`${e.type}:${e.range?.[0]}:${e.range?.[1]}`);
|
|
903
907
|
e._blockId = n;
|
|
904
|
-
let r =
|
|
908
|
+
let r = L(e), i = ve(e), a = {
|
|
905
909
|
id: n,
|
|
906
910
|
type: e.type,
|
|
907
911
|
range: e.range,
|
|
@@ -924,16 +928,16 @@ function U(e, t) {
|
|
|
924
928
|
sem: null
|
|
925
929
|
};
|
|
926
930
|
if (e.attrs) {
|
|
927
|
-
let n =
|
|
931
|
+
let n = D(e.attrs);
|
|
928
932
|
t.sem = n, t.predicates = n.predicates || [], t.subject = n.subject, t.types = n.types || [];
|
|
929
933
|
}
|
|
930
934
|
a.carriers.push(t);
|
|
931
935
|
}
|
|
932
936
|
return t.origin.blocks.set(n, a), t.origin.documentStructure.push(a), a;
|
|
933
937
|
}
|
|
934
|
-
function
|
|
938
|
+
function ke(e, t, n, r) {
|
|
935
939
|
if (t.subject && t.subject !== "RESET") {
|
|
936
|
-
let n =
|
|
940
|
+
let n = k(t, r);
|
|
937
941
|
n && (e.subject = n.value);
|
|
938
942
|
}
|
|
939
943
|
if (t.types && t.types.length > 0 && t.types.forEach((t) => {
|
|
@@ -955,26 +959,26 @@ function we(e, t, n, r) {
|
|
|
955
959
|
predicates: []
|
|
956
960
|
};
|
|
957
961
|
if (n.attrs) {
|
|
958
|
-
let e =
|
|
962
|
+
let e = D(n.attrs);
|
|
959
963
|
t.sem = e, t.predicates = e.predicates || [], t.subject = e.subject, t.types = e.types || [];
|
|
960
964
|
}
|
|
961
965
|
e.carriers.push(t);
|
|
962
966
|
}
|
|
963
967
|
}
|
|
964
|
-
function
|
|
968
|
+
function Ae(e, t, n, r = {}) {
|
|
965
969
|
let { preserveGlobalSubject: i = !1, implicitSubject: a = null } = r;
|
|
966
970
|
if (t.subject === "RESET") {
|
|
967
971
|
n.currentSubject = null;
|
|
968
972
|
return;
|
|
969
973
|
}
|
|
970
|
-
let o = n.currentSubject, s =
|
|
974
|
+
let o = n.currentSubject, s = k(t, n), c = be(t, n);
|
|
971
975
|
s && !n.primarySubject && !t.subject.startsWith("=#") && (n.primarySubject = s.value), s && !i && !a && (n.currentSubject = s);
|
|
972
976
|
let l = i ? s || o : a || n.currentSubject;
|
|
973
977
|
if (!l) return;
|
|
974
|
-
let u =
|
|
975
|
-
n.currentBlock &&
|
|
978
|
+
let u = je(l.value, t.types, t.predicates, e.range, e.attrsRange || null, e.valueRange || null, e.type || null, n.ctx, e.text), d = ne(e.text, t.datatype, t.language, n.ctx, n.df), f = e.url ? n.df.namedNode(h(e.url, n.ctx)) : null, p = s || f;
|
|
979
|
+
n.currentBlock && ke(n.currentBlock, t, e, n), Pe(t, s, c, f, l, u, n, e), Ie(t, s, o, c, p, l, d, u, n, e);
|
|
976
980
|
}
|
|
977
|
-
function
|
|
981
|
+
function je(e, t, n, r, i, a, o, s, c) {
|
|
978
982
|
let l = {
|
|
979
983
|
subject: e,
|
|
980
984
|
types: t.map((e) => h(typeof e == "string" ? e : e.iri, s)),
|
|
@@ -1002,7 +1006,7 @@ function Ee(e, t, n, r, i, a, o, s, c) {
|
|
|
1002
1006
|
text: c || ""
|
|
1003
1007
|
};
|
|
1004
1008
|
}
|
|
1005
|
-
function
|
|
1009
|
+
function z(e, t, n, r, i, a, o, s, c, l = null, u = null, d = null, f = null) {
|
|
1006
1010
|
if (!a || !o || !s) return;
|
|
1007
1011
|
let p = c.quad(a, o, s);
|
|
1008
1012
|
if (l?.remove) {
|
|
@@ -1014,12 +1018,12 @@ function W(e, t, n, r, i, a, o, s, c, l = null, u = null, d = null, f = null) {
|
|
|
1014
1018
|
} else n.add(p);
|
|
1015
1019
|
} else {
|
|
1016
1020
|
let n = v(p.subject, p.predicate, p.object);
|
|
1017
|
-
t.set(n, p), e.push(p),
|
|
1018
|
-
let
|
|
1019
|
-
r.set(n,
|
|
1021
|
+
t.set(n, p), e.push(p), f && (!f.primaryType && o.value === "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" && (f.primaryType = s.value), !f.primaryLabel && o.value === "http://www.w3.org/2000/01/rdf-schema#label" && s.termType === "Literal" && (f.primaryLabel = s.value)), Me(p, c, l, u, d);
|
|
1022
|
+
let m = ye(i, a, o, l);
|
|
1023
|
+
r.set(n, m), f.currentBlock && i.id === f.currentBlock.id && (f.currentBlock.quadKeys || (f.currentBlock.quadKeys = []), f.currentBlock.quadKeys.push(n));
|
|
1020
1024
|
}
|
|
1021
1025
|
}
|
|
1022
|
-
function
|
|
1026
|
+
function Me(e, t, n, r = null, i = null) {
|
|
1023
1027
|
if (!r || !i) return;
|
|
1024
1028
|
let a = e.predicate.value;
|
|
1025
1029
|
if (a !== "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" && a !== "http://www.w3.org/1999/02/22-rdf-syntax-ns#subject" && a !== "http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate" && a !== "http://www.w3.org/1999/02/22-rdf-syntax-ns#object") return;
|
|
@@ -1033,12 +1037,12 @@ function De(e, t, n, r = null, i = null) {
|
|
|
1033
1037
|
r.push(n), i.delete(e.subject.value);
|
|
1034
1038
|
}
|
|
1035
1039
|
}
|
|
1036
|
-
var
|
|
1040
|
+
var Ne = (e, t, n, r, i = null) => {
|
|
1037
1041
|
let a = h(e, n.ctx), o = typeof i == "object" ? i : {
|
|
1038
1042
|
entryIndex: i,
|
|
1039
1043
|
remove: !1
|
|
1040
1044
|
};
|
|
1041
|
-
|
|
1045
|
+
z(n.quads, n.quadBuffer, n.removeSet, n.origin.quadIndex, r, t, n.df.namedNode(h("rdf:type", n.ctx)), n.df.namedNode(a), n.df, {
|
|
1042
1046
|
kind: "type",
|
|
1043
1047
|
token: `.${e}`,
|
|
1044
1048
|
expandedType: a,
|
|
@@ -1046,15 +1050,15 @@ var Oe = (e, t, n, r, i = null) => {
|
|
|
1046
1050
|
remove: o.remove
|
|
1047
1051
|
}, n.statements, n.statementCandidates, n);
|
|
1048
1052
|
};
|
|
1049
|
-
function
|
|
1053
|
+
function Pe(e, t, n, r, i, a, o, s) {
|
|
1050
1054
|
e.types.forEach((e) => {
|
|
1051
|
-
|
|
1055
|
+
Ne(typeof e == "string" ? e : e.iri, t || n || r || i, o, a, typeof e == "string" ? {
|
|
1052
1056
|
entryIndex: null,
|
|
1053
1057
|
remove: !1
|
|
1054
1058
|
} : e);
|
|
1055
1059
|
});
|
|
1056
1060
|
}
|
|
1057
|
-
var
|
|
1061
|
+
var Fe = (e, t, n, r, i, a, o, s) => {
|
|
1058
1062
|
if (e.form === "" && t?.type === "link" && t?.url && t.text === t.url) return null;
|
|
1059
1063
|
switch (e.form) {
|
|
1060
1064
|
case "": return n ? {
|
|
@@ -1078,12 +1082,12 @@ var Ae = (e, t, n, r, i, a, o, s) => {
|
|
|
1078
1082
|
default: return null;
|
|
1079
1083
|
}
|
|
1080
1084
|
};
|
|
1081
|
-
function
|
|
1085
|
+
function Ie(e, t, n, r, i, a, o, s, c, l) {
|
|
1082
1086
|
e.predicates.forEach((e) => {
|
|
1083
|
-
let u =
|
|
1087
|
+
let u = Fe(e, l, t, n, r, i, a, o);
|
|
1084
1088
|
if (u) {
|
|
1085
1089
|
let t = c.df.namedNode(h(e.iri, c.ctx));
|
|
1086
|
-
|
|
1090
|
+
z(c.quads, c.quadBuffer, c.removeSet, c.origin.quadIndex, s, u.subject, t, u.object, c.df, {
|
|
1087
1091
|
kind: "pred",
|
|
1088
1092
|
token: `${e.form}${e.iri}`,
|
|
1089
1093
|
form: e.form,
|
|
@@ -1094,13 +1098,13 @@ function je(e, t, n, r, i, a, o, s, c, l) {
|
|
|
1094
1098
|
}
|
|
1095
1099
|
});
|
|
1096
1100
|
}
|
|
1097
|
-
function
|
|
1098
|
-
|
|
1101
|
+
function B(e, t, n, r = {}) {
|
|
1102
|
+
Ae(e, t, n, r);
|
|
1099
1103
|
}
|
|
1100
|
-
function
|
|
1104
|
+
function V(e, t, n) {
|
|
1101
1105
|
if (e.attrs) {
|
|
1102
|
-
let r =
|
|
1103
|
-
|
|
1106
|
+
let r = D(e.attrs);
|
|
1107
|
+
B({
|
|
1104
1108
|
type: n,
|
|
1105
1109
|
text: e.text,
|
|
1106
1110
|
range: e.range,
|
|
@@ -1108,15 +1112,15 @@ function K(e, t, n) {
|
|
|
1108
1112
|
valueRange: e.valueRange || null
|
|
1109
1113
|
}, r, t);
|
|
1110
1114
|
}
|
|
1111
|
-
|
|
1112
|
-
e.attrs &&
|
|
1115
|
+
L(e).forEach((e) => {
|
|
1116
|
+
e.attrs && B(e, D(e.attrs), t);
|
|
1113
1117
|
});
|
|
1114
1118
|
}
|
|
1115
|
-
function
|
|
1116
|
-
let n =
|
|
1119
|
+
function H(e, t) {
|
|
1120
|
+
let n = se(e.text);
|
|
1117
1121
|
if (!n) return;
|
|
1118
|
-
let r =
|
|
1119
|
-
|
|
1122
|
+
let r = D(`{=${n.content}}`), i = e.range[0] + e.text.indexOf("{=");
|
|
1123
|
+
B({
|
|
1120
1124
|
type: "standalone",
|
|
1121
1125
|
text: "",
|
|
1122
1126
|
range: e.range,
|
|
@@ -1124,21 +1128,21 @@ function q(e, t) {
|
|
|
1124
1128
|
valueRange: null
|
|
1125
1129
|
}, r, t);
|
|
1126
1130
|
}
|
|
1127
|
-
var
|
|
1128
|
-
heading: (e, t) =>
|
|
1129
|
-
code: (e, t) =>
|
|
1130
|
-
blockquote: (e, t) =>
|
|
1131
|
-
para: (e, t) =>
|
|
1132
|
-
list: (e, t) =>
|
|
1133
|
-
standalone: (e, t) =>
|
|
1131
|
+
var Le = {
|
|
1132
|
+
heading: (e, t) => P(e, t, V, R),
|
|
1133
|
+
code: (e, t) => P(e, t, V, R),
|
|
1134
|
+
blockquote: (e, t) => P(e, t, V, R),
|
|
1135
|
+
para: (e, t) => P(e, t, V, R, [H]),
|
|
1136
|
+
list: (e, t) => P(e, t, V, R),
|
|
1137
|
+
standalone: (e, t) => H(e, t)
|
|
1134
1138
|
};
|
|
1135
1139
|
//#endregion
|
|
1136
1140
|
//#region src/merge.js
|
|
1137
|
-
function
|
|
1138
|
-
return
|
|
1141
|
+
function U(e) {
|
|
1142
|
+
return te(e);
|
|
1139
1143
|
}
|
|
1140
|
-
function
|
|
1141
|
-
return typeof e == "string" ?
|
|
1144
|
+
function Re(e, t, n) {
|
|
1145
|
+
return typeof e == "string" ? I({
|
|
1142
1146
|
text: e,
|
|
1143
1147
|
...t,
|
|
1144
1148
|
context: {
|
|
@@ -1147,10 +1151,10 @@ function Ne(e, t, n) {
|
|
|
1147
1151
|
}
|
|
1148
1152
|
}) : e;
|
|
1149
1153
|
}
|
|
1150
|
-
function
|
|
1154
|
+
function ze(t, n = {}) {
|
|
1151
1155
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = [], o = /* @__PURE__ */ new Map(), s = [], c = /* @__PURE__ */ new Map(), l = [];
|
|
1152
1156
|
for (let u = 0; u < t.length; u++) {
|
|
1153
|
-
let d = t[u], f =
|
|
1157
|
+
let d = t[u], f = Re(d, n, {
|
|
1154
1158
|
...e,
|
|
1155
1159
|
...n.context
|
|
1156
1160
|
});
|
|
@@ -1164,7 +1168,7 @@ function Pe(t, n = {}) {
|
|
|
1164
1168
|
};
|
|
1165
1169
|
a.push(p), f.statements && f.statements.length > 0 && s.push(...f.statements), f.primarySubject && l.push(f.primarySubject);
|
|
1166
1170
|
for (let e of f.quads) {
|
|
1167
|
-
let t =
|
|
1171
|
+
let t = U(e);
|
|
1168
1172
|
r.set(t, e);
|
|
1169
1173
|
let n = f.origin.quadIndex.get(t);
|
|
1170
1174
|
o.set(t, {
|
|
@@ -1174,7 +1178,7 @@ function Pe(t, n = {}) {
|
|
|
1174
1178
|
});
|
|
1175
1179
|
}
|
|
1176
1180
|
for (let e of f.remove) {
|
|
1177
|
-
let t =
|
|
1181
|
+
let t = U(e);
|
|
1178
1182
|
r.has(t) ? r.delete(t) : i.add(e);
|
|
1179
1183
|
let n = f.origin.quadIndex.get(t);
|
|
1180
1184
|
o.set(t, {
|
|
@@ -1191,10 +1195,10 @@ function Pe(t, n = {}) {
|
|
|
1191
1195
|
...e,
|
|
1192
1196
|
...n.context,
|
|
1193
1197
|
...Object.fromEntries(c)
|
|
1194
|
-
}, m = new Set(u.map(
|
|
1198
|
+
}, m = new Set(u.map(U)), h = new Set(d.map(U));
|
|
1195
1199
|
return {
|
|
1196
|
-
quads: u.filter((e) => !h.has(
|
|
1197
|
-
remove: d.filter((e) => !m.has(
|
|
1200
|
+
quads: u.filter((e) => !h.has(U(e))),
|
|
1201
|
+
remove: d.filter((e) => !m.has(U(e))),
|
|
1198
1202
|
statements: s,
|
|
1199
1203
|
origin: f,
|
|
1200
1204
|
context: p,
|
|
@@ -1203,14 +1207,14 @@ function Pe(t, n = {}) {
|
|
|
1203
1207
|
}
|
|
1204
1208
|
//#endregion
|
|
1205
1209
|
//#region src/generate.js
|
|
1206
|
-
var
|
|
1207
|
-
function
|
|
1210
|
+
var W = /* @__PURE__ */ new Map(), G = 1e3;
|
|
1211
|
+
function K(e, t) {
|
|
1208
1212
|
let n = `${e}|${JSON.stringify(t)}`;
|
|
1209
|
-
if (
|
|
1213
|
+
if (W.has(n)) return W.get(n);
|
|
1210
1214
|
let r = g(e, t);
|
|
1211
|
-
return
|
|
1215
|
+
return W.size >= G && Array.from(W.keys()).slice(0, Math.floor(G / 2)).forEach((e) => W.delete(e)), W.set(n, r), r;
|
|
1212
1216
|
}
|
|
1213
|
-
function
|
|
1217
|
+
function Be(e, t = {}) {
|
|
1214
1218
|
if (!e) return e;
|
|
1215
1219
|
for (let [n, r] of Object.entries(t)) if (e.startsWith(r) || e.startsWith(r.slice(0, -1))) return e.substring(r.length);
|
|
1216
1220
|
for (let t of [
|
|
@@ -1223,32 +1227,32 @@ function Ie(e, t = {}) {
|
|
|
1223
1227
|
}
|
|
1224
1228
|
return e;
|
|
1225
1229
|
}
|
|
1226
|
-
function
|
|
1227
|
-
let i = Object.assign({}, e, n), a =
|
|
1230
|
+
function Ve({ quads: t, context: n = {}, primarySubject: r = null }) {
|
|
1231
|
+
let i = Object.assign({}, e, n), a = Ue(t), o = We(a), s = r;
|
|
1228
1232
|
!s && a.length > 0 && (s = a[0].subject.value);
|
|
1229
|
-
let { text: c } =
|
|
1233
|
+
let { text: c } = Ke(o, i, s);
|
|
1230
1234
|
return {
|
|
1231
1235
|
text: c,
|
|
1232
1236
|
context: i
|
|
1233
1237
|
};
|
|
1234
1238
|
}
|
|
1235
|
-
function
|
|
1239
|
+
function He({ quads: t, focusIRI: n, context: r = {} }) {
|
|
1236
1240
|
if (!t?.length || !n) return {
|
|
1237
1241
|
text: "",
|
|
1238
1242
|
context: Object.assign({}, e, r)
|
|
1239
1243
|
};
|
|
1240
|
-
let i = Object.assign({}, e, r), a =
|
|
1244
|
+
let i = Object.assign({}, e, r), a = Ge(Ue(t));
|
|
1241
1245
|
if (!a.has(n)) return {
|
|
1242
1246
|
text: "",
|
|
1243
1247
|
context: i
|
|
1244
1248
|
};
|
|
1245
|
-
let { text: o } =
|
|
1249
|
+
let { text: o } = Ke(a, i, n);
|
|
1246
1250
|
return {
|
|
1247
1251
|
text: o,
|
|
1248
1252
|
context: i
|
|
1249
1253
|
};
|
|
1250
1254
|
}
|
|
1251
|
-
function
|
|
1255
|
+
function Ue(e) {
|
|
1252
1256
|
return !e || e.length === 0 ? [] : e.map((e) => e.subject.termType && e.predicate.termType && e.object.termType ? e : {
|
|
1253
1257
|
subject: d.fromTerm(e.subject),
|
|
1254
1258
|
predicate: d.fromTerm(e.predicate),
|
|
@@ -1258,11 +1262,11 @@ function ze(e) {
|
|
|
1258
1262
|
if (n !== 0) return n;
|
|
1259
1263
|
let r = e.predicate.value.localeCompare(t.predicate.value);
|
|
1260
1264
|
if (r !== 0) return r;
|
|
1261
|
-
let i = (
|
|
1265
|
+
let i = (j(e.object), e.object.value), a = (j(t.object), t.object.value);
|
|
1262
1266
|
return i.localeCompare(a);
|
|
1263
1267
|
});
|
|
1264
1268
|
}
|
|
1265
|
-
function
|
|
1269
|
+
function We(e) {
|
|
1266
1270
|
let t = /* @__PURE__ */ new Map();
|
|
1267
1271
|
for (let n of e) {
|
|
1268
1272
|
let e = n.subject.value, r = t.get(e);
|
|
@@ -1270,7 +1274,7 @@ function Be(e) {
|
|
|
1270
1274
|
}
|
|
1271
1275
|
return t;
|
|
1272
1276
|
}
|
|
1273
|
-
function
|
|
1277
|
+
function Ge(e) {
|
|
1274
1278
|
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
1275
1279
|
let n = t.get(e);
|
|
1276
1280
|
if (n) return n;
|
|
@@ -1283,40 +1287,40 @@ function Ve(e) {
|
|
|
1283
1287
|
}
|
|
1284
1288
|
return t;
|
|
1285
1289
|
}
|
|
1286
|
-
function
|
|
1287
|
-
let i = [], a =
|
|
1288
|
-
for (let [t, n] of s) t !== "@vocab" && !t.startsWith("@") && !e[t] && a.has(t) && i.push(
|
|
1290
|
+
function Ke(t, n, r = null) {
|
|
1291
|
+
let i = [], a = Se(t, n), o = qe(t), s = Object.entries(n).sort(([e], [t]) => e.localeCompare(t));
|
|
1292
|
+
for (let [t, n] of s) t !== "@vocab" && !t.startsWith("@") && !e[t] && a.has(t) && i.push(Ce(t, n));
|
|
1289
1293
|
s.length > 0 && i.push("\n");
|
|
1290
1294
|
let c = Array.from(t.keys()).sort(), l = r, u = l ? [l, ...c.filter((e) => e !== l)] : c;
|
|
1291
1295
|
for (let e of u) {
|
|
1292
1296
|
let r = t.get(e);
|
|
1293
1297
|
if (!r) continue;
|
|
1294
|
-
let a =
|
|
1298
|
+
let a = K(e, n), { types: s, literals: c, objects: l } = Ee(r), u = o.has(e), d = u ? o.get(e) : Be(e, n), f = s.length > 0 ? s.map((e) => "." + K(e.object.value, n)).sort().join(" ") : "";
|
|
1295
1299
|
u && (f += (f ? " " : "") + "label");
|
|
1296
1300
|
let p = f ? " " + f : "";
|
|
1297
1301
|
i.push(`# ${d} {=${a}${p}}\n\n`);
|
|
1298
1302
|
let m = u ? o.get(e) : null;
|
|
1299
|
-
|
|
1300
|
-
e.predicate.value === "http://www.w3.org/2000/01/rdf-schema#label" && e.object.value === m || i.push(
|
|
1301
|
-
}),
|
|
1302
|
-
i.push(
|
|
1303
|
+
F(c).forEach((e) => {
|
|
1304
|
+
e.predicate.value === "http://www.w3.org/2000/01/rdf-schema#label" && e.object.value === m || i.push(we(e, n));
|
|
1305
|
+
}), F(l).forEach((e) => {
|
|
1306
|
+
i.push(Te(e, n, o));
|
|
1303
1307
|
}), i.push("\n");
|
|
1304
1308
|
}
|
|
1305
1309
|
return { text: i.join("") };
|
|
1306
1310
|
}
|
|
1307
|
-
function
|
|
1311
|
+
function qe(e) {
|
|
1308
1312
|
let t = /* @__PURE__ */ new Map();
|
|
1309
1313
|
for (let n of e.values()) for (let e of n) e.predicate.value === "http://www.w3.org/2000/01/rdf-schema#label" && e.object.termType === "Literal" && t.set(e.subject.value, e.object.value);
|
|
1310
1314
|
return t;
|
|
1311
1315
|
}
|
|
1312
1316
|
//#endregion
|
|
1313
1317
|
//#region src/render.js
|
|
1314
|
-
function
|
|
1315
|
-
let n =
|
|
1318
|
+
function Je(e, t = {}) {
|
|
1319
|
+
let n = I({
|
|
1316
1320
|
text: e,
|
|
1317
1321
|
context: t.context || {}
|
|
1318
|
-
}), r =
|
|
1319
|
-
html:
|
|
1322
|
+
}), r = Ye(n, t, e), i = {
|
|
1323
|
+
html: ht(Xe(n.origin.blocks, r), r.ctx),
|
|
1320
1324
|
context: r.ctx,
|
|
1321
1325
|
metadata: {
|
|
1322
1326
|
blockCount: n.origin.blocks.size,
|
|
@@ -1331,7 +1335,7 @@ function We(e, t = {}) {
|
|
|
1331
1335
|
renderMap: r.renderMap
|
|
1332
1336
|
}), i;
|
|
1333
1337
|
}
|
|
1334
|
-
function
|
|
1338
|
+
function Ye(t, n, r) {
|
|
1335
1339
|
return {
|
|
1336
1340
|
ctx: t.context || {
|
|
1337
1341
|
...e,
|
|
@@ -1349,49 +1353,49 @@ function Ge(t, n, r) {
|
|
|
1349
1353
|
validation: n.validate || !1
|
|
1350
1354
|
};
|
|
1351
1355
|
}
|
|
1352
|
-
function
|
|
1356
|
+
function Xe(e, t) {
|
|
1353
1357
|
let n = Array.from(e.values()).sort((e, t) => (e.range?.start || 0) - (t.range?.start || 0)), r = n.filter((e) => e.carrierType === "list");
|
|
1354
1358
|
return n.filter((e) => e.carrierType !== "list").forEach((e) => {
|
|
1355
|
-
|
|
1356
|
-
}), r.length > 0 &&
|
|
1359
|
+
Ze(e, t);
|
|
1360
|
+
}), r.length > 0 && lt(r, t), t.output.join("");
|
|
1357
1361
|
}
|
|
1358
|
-
function
|
|
1362
|
+
function Ze(e, t) {
|
|
1359
1363
|
e.subject && e.subject !== "RESET" && (t.currentSubject = e.subject);
|
|
1360
|
-
let n =
|
|
1361
|
-
switch (n && t.renderMap.set(e.id ||
|
|
1364
|
+
let n = Qe(e, t);
|
|
1365
|
+
switch (n && t.renderMap.set(e.id || gt(e), n), e.type || e.carrierType) {
|
|
1362
1366
|
case "heading":
|
|
1363
|
-
|
|
1367
|
+
et(e, n, t);
|
|
1364
1368
|
break;
|
|
1365
1369
|
case "para":
|
|
1366
|
-
|
|
1370
|
+
tt(e, n, t);
|
|
1367
1371
|
break;
|
|
1368
1372
|
case "list": break;
|
|
1369
1373
|
case "quote":
|
|
1370
|
-
|
|
1374
|
+
nt(e, n, t);
|
|
1371
1375
|
break;
|
|
1372
1376
|
case "code":
|
|
1373
|
-
|
|
1377
|
+
rt(e, n, t);
|
|
1374
1378
|
break;
|
|
1375
|
-
default:
|
|
1379
|
+
default: it(e, n, t);
|
|
1376
1380
|
}
|
|
1377
1381
|
}
|
|
1378
|
-
function
|
|
1382
|
+
function Qe(e, t) {
|
|
1379
1383
|
let n = [];
|
|
1380
1384
|
if (!e.subject || e.subject === "RESET" || e.subject.startsWith("=#") || e.subject.startsWith("+")) return "";
|
|
1381
1385
|
let r = h(e.subject, t.ctx);
|
|
1382
|
-
if (n.push(`about="${
|
|
1386
|
+
if (n.push(`about="${A(r)}"`), e.types && e.types.length > 0) {
|
|
1383
1387
|
let r = e.types.map((e) => h(typeof e == "string" ? e : e.iri, t.ctx)).join(" ");
|
|
1384
|
-
n.push(`typeof="${
|
|
1388
|
+
n.push(`typeof="${A(r)}"`);
|
|
1385
1389
|
}
|
|
1386
1390
|
let i = [];
|
|
1387
1391
|
if (e.predicates && e.predicates.length > 0 && i.push(...e.predicates), e.carriers && e.carriers.length > 0) for (let t of e.carriers) t.predicates && t.predicates.length > 0 && i.push(...t.predicates);
|
|
1388
1392
|
if (i.length > 0) {
|
|
1389
|
-
let { literalProps: e, objectProps: r, reverseProps: a } =
|
|
1390
|
-
e.length > 0 && n.push(`property="${
|
|
1393
|
+
let { literalProps: e, objectProps: r, reverseProps: a } = $e(i, t.ctx);
|
|
1394
|
+
e.length > 0 && n.push(`property="${A(e.join(" "))}"`), r.length > 0 && n.push(`rel="${A(r.join(" "))}"`), a.length > 0 && n.push(`rev="${A(a.join(" "))}"`);
|
|
1391
1395
|
}
|
|
1392
1396
|
return n.length > 1 && t.renderedRDFaCount++, n.length > 0 ? ` ${n.join(" ")}` : "";
|
|
1393
1397
|
}
|
|
1394
|
-
function
|
|
1398
|
+
function $e(e, t) {
|
|
1395
1399
|
let n = [], r = [], i = [];
|
|
1396
1400
|
for (let a of e) {
|
|
1397
1401
|
let e = h(typeof a == "string" ? a : a.iri, t);
|
|
@@ -1403,37 +1407,37 @@ function Ye(e, t) {
|
|
|
1403
1407
|
reverseProps: i
|
|
1404
1408
|
};
|
|
1405
1409
|
}
|
|
1406
|
-
function
|
|
1407
|
-
let r = `h${e.text && e.text.match(/^#+/)?.[0]?.length || 1}`, i =
|
|
1408
|
-
i = i.replace(/\s*\{[^}]+\}\s*$/g, "").trim(), n.output.push(`<${r}${t}>${
|
|
1410
|
+
function et(e, t, n) {
|
|
1411
|
+
let r = `h${e.text && e.text.match(/^#+/)?.[0]?.length || 1}`, i = _e(n.sourceText, e.range);
|
|
1412
|
+
i = i.replace(/\s*\{[^}]+\}\s*$/g, "").trim(), n.output.push(`<${r}${t}>${A(i)}</${r}>`);
|
|
1409
1413
|
}
|
|
1410
|
-
function
|
|
1411
|
-
let r =
|
|
1414
|
+
function tt(e, t, n) {
|
|
1415
|
+
let r = q(e, n);
|
|
1412
1416
|
n.output.push(`<p${t}>${r}</p>`);
|
|
1413
1417
|
}
|
|
1414
|
-
function
|
|
1415
|
-
let r =
|
|
1418
|
+
function nt(e, t, n) {
|
|
1419
|
+
let r = q(e, n);
|
|
1416
1420
|
n.output.push(`<blockquote${t}>${r}</blockquote>`);
|
|
1417
1421
|
}
|
|
1418
|
-
function
|
|
1422
|
+
function rt(e, t, n) {
|
|
1419
1423
|
let r = e.info || "", i = e.text || "";
|
|
1420
|
-
n.output.push(`<pre><code${t}${r ? ` class="language-${
|
|
1424
|
+
n.output.push(`<pre><code${t}${r ? ` class="language-${A(r)}"` : ""}>${A(i)}</code></pre>`);
|
|
1421
1425
|
}
|
|
1422
|
-
function
|
|
1423
|
-
let r =
|
|
1426
|
+
function it(e, t, n) {
|
|
1427
|
+
let r = q(e, n);
|
|
1424
1428
|
n.output.push(`<div${t}>${r}</div>`);
|
|
1425
1429
|
}
|
|
1426
|
-
function
|
|
1427
|
-
if (!e.carriers || e.carriers.length === 0) return
|
|
1428
|
-
let n =
|
|
1429
|
-
return
|
|
1430
|
+
function q(e, t) {
|
|
1431
|
+
if (!e.carriers || e.carriers.length === 0) return A(at(t.sourceText, e.range));
|
|
1432
|
+
let n = ot(e);
|
|
1433
|
+
return st(at(t.sourceText, e.range), n, t);
|
|
1430
1434
|
}
|
|
1431
|
-
function
|
|
1435
|
+
function at(e, t) {
|
|
1432
1436
|
if (!t || !e) return "";
|
|
1433
1437
|
let n = e.substring(t[0], t[1]);
|
|
1434
1438
|
return n = n.replace(/\s*\{[^}]*\}\s*$/gm, ""), n = n.replace(/\{[^}]*\}/g, ""), n = n.replace(/\s+/g, " ").trim(), n = n.replace(/\]$/, ""), n;
|
|
1435
1439
|
}
|
|
1436
|
-
function
|
|
1440
|
+
function ot(e) {
|
|
1437
1441
|
let t = [];
|
|
1438
1442
|
if (!e.carriers) return t;
|
|
1439
1443
|
for (let n of e.carriers) !n.text || !n.range || t.push({
|
|
@@ -1443,52 +1447,52 @@ function nt(e) {
|
|
|
1443
1447
|
});
|
|
1444
1448
|
return t.sort((e, t) => e.pos - t.pos);
|
|
1445
1449
|
}
|
|
1446
|
-
function
|
|
1447
|
-
if (t.length === 0) return
|
|
1450
|
+
function st(e, t, n) {
|
|
1451
|
+
if (t.length === 0) return A(e);
|
|
1448
1452
|
let r = "", i = 0;
|
|
1449
|
-
for (let a of t) a.pos > i && (r +=
|
|
1450
|
-
return i < e.length && (r +=
|
|
1453
|
+
for (let a of t) a.pos > i && (r += A(e.substring(i, a.pos))), r += ct(a.carrier, n), i = a.pos + a.length;
|
|
1454
|
+
return i < e.length && (r += A(e.substring(i))), r;
|
|
1451
1455
|
}
|
|
1452
|
-
function
|
|
1456
|
+
function ct(e, t) {
|
|
1453
1457
|
let n = [], r = e.subject || t.currentSubject;
|
|
1454
|
-
if (!r || r === "RESET" || r.startsWith("=#") || r.startsWith("+")) return
|
|
1458
|
+
if (!r || r === "RESET" || r.startsWith("=#") || r.startsWith("+")) return A(e.text || "");
|
|
1455
1459
|
let i = g(h(r, t.ctx), t.ctx);
|
|
1456
|
-
if (n.push(`about="${
|
|
1460
|
+
if (n.push(`about="${A(i)}"`), e.types && e.types.length > 0) {
|
|
1457
1461
|
let r = e.types.map((e) => g(h(typeof e == "string" ? e : e.iri, t.ctx), t.ctx)).join(" ");
|
|
1458
|
-
n.push(`typeof="${
|
|
1462
|
+
n.push(`typeof="${A(r)}"`);
|
|
1459
1463
|
}
|
|
1460
1464
|
if (e.predicates && e.predicates.length > 0) {
|
|
1461
|
-
let { literalProps: r, objectProps: i, reverseProps: a } =
|
|
1465
|
+
let { literalProps: r, objectProps: i, reverseProps: a } = $e(e.predicates, t.ctx);
|
|
1462
1466
|
if (r.length > 0) {
|
|
1463
1467
|
let e = r.map((e) => g(e, t.ctx)).join(" ");
|
|
1464
|
-
n.push(`property="${
|
|
1468
|
+
n.push(`property="${A(e)}"`);
|
|
1465
1469
|
}
|
|
1466
1470
|
if (i.length > 0) {
|
|
1467
1471
|
let e = i.map((e) => g(e, t.ctx)).join(" ");
|
|
1468
|
-
n.push(`rel="${
|
|
1472
|
+
n.push(`rel="${A(e)}"`);
|
|
1469
1473
|
}
|
|
1470
1474
|
if (a.length > 0) {
|
|
1471
1475
|
let e = a.map((e) => g(e, t.ctx)).join(" ");
|
|
1472
|
-
n.push(`rev="${
|
|
1476
|
+
n.push(`rev="${A(e)}"`);
|
|
1473
1477
|
}
|
|
1474
1478
|
}
|
|
1475
1479
|
let a = n.length > 0 ? ` ${n.join(" ")}` : "";
|
|
1476
1480
|
switch (e.type) {
|
|
1477
|
-
case "emphasis": return `<em${a}>${
|
|
1478
|
-
case "strong": return `<strong${a}>${
|
|
1479
|
-
case "code": return `<code${a}>${
|
|
1480
|
-
case "link": return `<a href="${
|
|
1481
|
-
default: return `<span${a}>${
|
|
1481
|
+
case "emphasis": return `<em${a}>${A(e.text || "")}</em>`;
|
|
1482
|
+
case "strong": return `<strong${a}>${A(e.text || "")}</strong>`;
|
|
1483
|
+
case "code": return `<code${a}>${A(e.text || "")}</code>`;
|
|
1484
|
+
case "link": return `<a href="${A(e.url || "")}"${a}>${A(e.text || "")}</a>`;
|
|
1485
|
+
default: return `<span${a}>${A(e.text || "")}</span>`;
|
|
1482
1486
|
}
|
|
1483
1487
|
}
|
|
1484
|
-
function
|
|
1485
|
-
|
|
1486
|
-
|
|
1488
|
+
function lt(e, t) {
|
|
1489
|
+
ut(e, t.sourceText).forEach((e) => {
|
|
1490
|
+
dt(e, t);
|
|
1487
1491
|
});
|
|
1488
1492
|
}
|
|
1489
|
-
function
|
|
1493
|
+
function ut(e, t) {
|
|
1490
1494
|
let n = [], r = null, i = e.sort((e, t) => (e.range?.start || 0) - (t.range?.start || 0));
|
|
1491
|
-
for (let e of i)
|
|
1495
|
+
for (let e of i) ge(e, t) === 0 ? (r && n.push(r), r = {
|
|
1492
1496
|
contextName: "Items",
|
|
1493
1497
|
blocks: [e]
|
|
1494
1498
|
}) : r ? r.blocks.push(e) : r = {
|
|
@@ -1497,30 +1501,30 @@ function ot(e, t) {
|
|
|
1497
1501
|
};
|
|
1498
1502
|
return r && n.push(r), n;
|
|
1499
1503
|
}
|
|
1500
|
-
function
|
|
1504
|
+
function dt(e, t) {
|
|
1501
1505
|
t.output.push("<ul>");
|
|
1502
|
-
for (let n of e.blocks)
|
|
1506
|
+
for (let n of e.blocks) ft(n, t);
|
|
1503
1507
|
t.output.push("</ul>");
|
|
1504
1508
|
}
|
|
1505
|
-
function
|
|
1506
|
-
let n =
|
|
1509
|
+
function ft(e, t) {
|
|
1510
|
+
let n = Qe(e, t), r = q(e, t);
|
|
1507
1511
|
t.output.push(`<li${n}>${r}</li>`);
|
|
1508
1512
|
}
|
|
1509
|
-
function
|
|
1513
|
+
function pt(e) {
|
|
1510
1514
|
let t = [];
|
|
1511
1515
|
for (let [n, r] of Object.entries(e)) n !== "@vocab" && t.push(`${n}: ${r}`);
|
|
1512
1516
|
return t.length > 0 ? ` prefix="${t.join(" ")}"` : "";
|
|
1513
1517
|
}
|
|
1514
|
-
function
|
|
1518
|
+
function mt(e) {
|
|
1515
1519
|
return e["@vocab"] ? ` vocab="${e["@vocab"]}"` : "";
|
|
1516
1520
|
}
|
|
1517
|
-
function
|
|
1518
|
-
return `<div${
|
|
1521
|
+
function ht(e, t) {
|
|
1522
|
+
return `<div${pt(t)}${mt(t)}>${e}</div>`;
|
|
1519
1523
|
}
|
|
1520
|
-
function
|
|
1521
|
-
return
|
|
1524
|
+
function gt(e) {
|
|
1525
|
+
return _t(`${e.type || e.carrierType}|${e.subject || ""}|${e.text || ""}`);
|
|
1522
1526
|
}
|
|
1523
|
-
function
|
|
1527
|
+
function _t(e) {
|
|
1524
1528
|
let t = 0;
|
|
1525
1529
|
for (let n = 0; n < e.length; n++) {
|
|
1526
1530
|
let r = e.charCodeAt(n);
|
|
@@ -1530,8 +1534,80 @@ function pt(e) {
|
|
|
1530
1534
|
}
|
|
1531
1535
|
//#endregion
|
|
1532
1536
|
//#region src/highlight.js
|
|
1533
|
-
|
|
1534
|
-
|
|
1537
|
+
function J(e) {
|
|
1538
|
+
return String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
1539
|
+
}
|
|
1540
|
+
var Y = {
|
|
1541
|
+
text: "#6b7280",
|
|
1542
|
+
marker: "#f97316",
|
|
1543
|
+
retraction: "#dc2626",
|
|
1544
|
+
value: "#eab308",
|
|
1545
|
+
annotation: "#4b5563"
|
|
1546
|
+
};
|
|
1547
|
+
function X(e, t) {
|
|
1548
|
+
let n = t;
|
|
1549
|
+
for (; n < e.length && e[n] !== "\n" && e[n] !== "\r";) {
|
|
1550
|
+
if (e[n] === "{") return !0;
|
|
1551
|
+
n++;
|
|
1552
|
+
}
|
|
1553
|
+
return !1;
|
|
1554
|
+
}
|
|
1555
|
+
function vt(e, t) {
|
|
1556
|
+
let n = e[t];
|
|
1557
|
+
if (n === "*" && t + 1 < e.length && e[t + 1] === "*") {
|
|
1558
|
+
let n = e.indexOf("**", t + 2);
|
|
1559
|
+
if (n !== -1) {
|
|
1560
|
+
let r = e.slice(t + 2, n), i = X(e, n + 2) ? ` style="color: ${Y.marker}"` : "";
|
|
1561
|
+
return {
|
|
1562
|
+
html: `<span${i}>**</span><strong>${J(r)}</strong><span${i}>**</span>`,
|
|
1563
|
+
nextIndex: n + 2
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
if (n === "_" && t + 1 < e.length && e[t + 1] === "_") {
|
|
1568
|
+
let n = e.indexOf("__", t + 2);
|
|
1569
|
+
if (n !== -1) {
|
|
1570
|
+
let r = e.slice(t + 2, n), i = X(e, n + 2) ? ` style="color: ${Y.marker}"` : "";
|
|
1571
|
+
return {
|
|
1572
|
+
html: `<span${i}>__</span><strong>${J(r)}</strong><span${i}>__</span>`,
|
|
1573
|
+
nextIndex: n + 2
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
if (n === "*") {
|
|
1578
|
+
let n = e.indexOf("*", t + 1);
|
|
1579
|
+
if (n !== -1) {
|
|
1580
|
+
let r = e.slice(t + 1, n), i = X(e, n + 1) ? ` style="color: ${Y.marker}"` : "";
|
|
1581
|
+
return {
|
|
1582
|
+
html: `<span${i}>*</span><em>${J(r)}</em><span${i}>*</span>`,
|
|
1583
|
+
nextIndex: n + 1
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
if (n === "_") {
|
|
1588
|
+
let n = e.indexOf("_", t + 1);
|
|
1589
|
+
if (n !== -1) {
|
|
1590
|
+
let r = e.slice(t + 1, n), i = X(e, n + 1) ? ` style="color: ${Y.marker}"` : "";
|
|
1591
|
+
return {
|
|
1592
|
+
html: `<span${i}>_</span><em>${J(r)}</em><span${i}>_</span>`,
|
|
1593
|
+
nextIndex: n + 1
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
if (n === "`") {
|
|
1598
|
+
let n = e.indexOf("`", t + 1);
|
|
1599
|
+
if (n !== -1) {
|
|
1600
|
+
let r = e.slice(t + 1, n), i = X(e, n + 1) ? ` style="color: ${Y.marker}"` : "";
|
|
1601
|
+
return {
|
|
1602
|
+
html: `<span${i}>\`</span><code style="background-color:#7773">${J(r)}</code><span${i}>\`</span>`,
|
|
1603
|
+
nextIndex: n + 1
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
return null;
|
|
1608
|
+
}
|
|
1609
|
+
var Z = /* @__PURE__ */ new Map();
|
|
1610
|
+
function yt(e) {
|
|
1535
1611
|
let t = 0;
|
|
1536
1612
|
for (let n = 0; n < e.length; n++) {
|
|
1537
1613
|
let r = e.charCodeAt(n);
|
|
@@ -1539,10 +1615,160 @@ function $(e) {
|
|
|
1539
1615
|
}
|
|
1540
1616
|
return Math.abs(t);
|
|
1541
1617
|
}
|
|
1542
|
-
function
|
|
1543
|
-
if (
|
|
1544
|
-
let t =
|
|
1545
|
-
return
|
|
1618
|
+
function Q(e) {
|
|
1619
|
+
if (Z.has(e)) return Z.get(e);
|
|
1620
|
+
let t = yt(e), n = `hsl(${t % 360}, ${15 + t % 10}%, ${45 + t % 10}%)`;
|
|
1621
|
+
return Z.set(e, n), n;
|
|
1622
|
+
}
|
|
1623
|
+
function bt(t) {
|
|
1624
|
+
let n = /* @__PURE__ */ new Map(), r = /^\[(\w+)\]\s*<([^>]*)>\s*$/gm, i;
|
|
1625
|
+
for (; (i = r.exec(t)) !== null;) {
|
|
1626
|
+
let e = i[1], t = i[2];
|
|
1627
|
+
if (t.includes(":")) {
|
|
1628
|
+
let e = t.indexOf(":");
|
|
1629
|
+
if (e > 0) {
|
|
1630
|
+
let r = t.slice(0, e), i = t.slice(e + 1);
|
|
1631
|
+
n.has(r) && (t = n.get(r) + i);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
n.set(e, t);
|
|
1635
|
+
}
|
|
1636
|
+
for (let [t, r] of Object.entries(e)) t !== "@vocab" && n.set(t, r);
|
|
1637
|
+
return n;
|
|
1638
|
+
}
|
|
1639
|
+
function $(e, t, n) {
|
|
1640
|
+
let r = t ? Y.retraction : Y.text, i = e.indexOf(":");
|
|
1641
|
+
if (i > 0) {
|
|
1642
|
+
let t = e.slice(0, i), r = e.slice(i + 1);
|
|
1643
|
+
if (n.has(t)) {
|
|
1644
|
+
let e = n.get(t), i = Q(e), a = e + r, o = Q(a);
|
|
1645
|
+
return `<span style="color: ${i}">${J(t)}</span><span style="color: ${Y.marker}">:</span><span data-iri="${a}" style="color: ${o}">${J(r)}</span> `;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
return e.startsWith("http:") || e.startsWith("https:") || e.startsWith("tag:") || e.startsWith("urn:") ? `<span style="color: ${Q(e)}">${J(e)}</span> ` : `<span style="color: ${r}">${J(e)}</span> `;
|
|
1649
|
+
}
|
|
1650
|
+
function xt(e, t) {
|
|
1651
|
+
let n = e.trim().split(/\s+/), r = "", i = !1;
|
|
1652
|
+
for (let e = 0; e < n.length; e++) {
|
|
1653
|
+
let a = n[e];
|
|
1654
|
+
if (!a) continue;
|
|
1655
|
+
if (a.startsWith("=") || a.startsWith("+")) {
|
|
1656
|
+
let e = a[0], n = a.slice(1);
|
|
1657
|
+
r += `<span style="color: ${Y.marker}">${J(e)}</span>${$(n, !1, t)}`;
|
|
1658
|
+
continue;
|
|
1659
|
+
}
|
|
1660
|
+
if (a === "-") {
|
|
1661
|
+
i = !0, r += `<span style="color: ${Y.retraction}">${J(a)}</span> `;
|
|
1662
|
+
continue;
|
|
1663
|
+
}
|
|
1664
|
+
if (a.startsWith("-") && a.length > 1) {
|
|
1665
|
+
r += `<span style="color: ${Y.retraction}">${J(a)}</span> `;
|
|
1666
|
+
continue;
|
|
1667
|
+
}
|
|
1668
|
+
let o = i;
|
|
1669
|
+
if (i = !1, a.startsWith("?") || a.startsWith("!")) {
|
|
1670
|
+
let e = a[0], n = a.slice(1), i = o ? Y.retraction : Y.marker;
|
|
1671
|
+
r += `<span style="color: ${i}">${J(e)}</span>${$(n, o, t)}`;
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
if (a.startsWith("^^")) {
|
|
1675
|
+
let e = a.slice(2), n = o ? Y.retraction : Y.marker;
|
|
1676
|
+
r += `<span style="color: ${n}">${J("^^")}</span>${$(e, o, t)}`;
|
|
1677
|
+
continue;
|
|
1678
|
+
}
|
|
1679
|
+
if (a.startsWith("@")) {
|
|
1680
|
+
let e = a.slice(1), n = o ? Y.retraction : Y.marker;
|
|
1681
|
+
r += `<span style="color: ${n}">${J("@")}</span>${$(e, o, t)}`;
|
|
1682
|
+
continue;
|
|
1683
|
+
}
|
|
1684
|
+
if (a.startsWith(".")) {
|
|
1685
|
+
let e = a.slice(1), n = o ? Y.retraction : Y.marker;
|
|
1686
|
+
r += `<span style="color: ${n}">${J(".")}</span>${$(e, o, t)}`;
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
r += $(a, o, t);
|
|
1690
|
+
}
|
|
1691
|
+
return r.trim();
|
|
1692
|
+
}
|
|
1693
|
+
function St(e) {
|
|
1694
|
+
let t = bt(e), n = "", r = 0;
|
|
1695
|
+
for (; r < e.length;) {
|
|
1696
|
+
let i = e[r];
|
|
1697
|
+
if (i === "{") {
|
|
1698
|
+
let a = e.indexOf("}", r);
|
|
1699
|
+
if (a === -1) {
|
|
1700
|
+
n += J(i), r++;
|
|
1701
|
+
continue;
|
|
1702
|
+
}
|
|
1703
|
+
let o = xt(e.slice(r + 1, a), t);
|
|
1704
|
+
n += `<span style="color: ${Y.annotation}; opacity: 0.75">{</span>`, n += o, n += `<span style="color: ${Y.annotation}; opacity: 0.75">}</span>`, r = a + 1;
|
|
1705
|
+
continue;
|
|
1706
|
+
}
|
|
1707
|
+
if (i === "[") {
|
|
1708
|
+
let a = e.indexOf("]", r);
|
|
1709
|
+
if (a === -1) {
|
|
1710
|
+
n += J(i), r++;
|
|
1711
|
+
continue;
|
|
1712
|
+
}
|
|
1713
|
+
let o = e.slice(r + 1, a), s = a + 1;
|
|
1714
|
+
for (; s < e.length && /\s/.test(e[s]);) s++;
|
|
1715
|
+
if (s < e.length && e[s] === "<") {
|
|
1716
|
+
let i = e.indexOf(">", s);
|
|
1717
|
+
if (i !== -1) {
|
|
1718
|
+
let a = e.slice(s + 1, i), c = t.has(o) ? Q(t.get(o)) : Y.text;
|
|
1719
|
+
n += `<span style="color: ${Y.annotation}; opacity: 0.75">[</span><span style="color: ${c}">${J(o)}</span><span style="color: ${Y.annotation}; opacity: 0.75">]</span> <span style="color: ${Y.text}; opacity: 0.6"><${J(a)}></span>`, r = i + 1;
|
|
1720
|
+
continue;
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
let c = e.slice(r + 1, a), l = X(e, a + 1) ? Y.marker : Y.value, u = J(c);
|
|
1724
|
+
n += `<span style="color: ${l}; opacity: 0.85">[</span><span style=" opacity: 1.0">${u}</span><span style="color: ${l}; opacity: 0.85">]</span>`, r = a + 1;
|
|
1725
|
+
continue;
|
|
1726
|
+
}
|
|
1727
|
+
if (i === "*" || i === "_" || i === "`") {
|
|
1728
|
+
let t = vt(e, r);
|
|
1729
|
+
if (t) {
|
|
1730
|
+
n += t.html, r = t.nextIndex;
|
|
1731
|
+
continue;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
if (i === "#") {
|
|
1735
|
+
let i = 0, a = r;
|
|
1736
|
+
for (; a < e.length && e[a] === "#";) i++, a++;
|
|
1737
|
+
if (i <= 6 && (a >= e.length || e[a] === " " || e[a] === " ")) {
|
|
1738
|
+
let o = e.indexOf("\n", a), s = o === -1 ? e.length : o, c = e.slice(a, s).trim(), l = "", u = 0, d = c.indexOf("{");
|
|
1739
|
+
for (; d !== -1;) {
|
|
1740
|
+
let e = c.indexOf("}", d);
|
|
1741
|
+
if (e === -1) break;
|
|
1742
|
+
let n = c.slice(u, d);
|
|
1743
|
+
l += J(n);
|
|
1744
|
+
let r = xt(c.slice(d + 1, e), t);
|
|
1745
|
+
l += `<span style="color: ${Y.annotation}; opacity: 0.75">{</span>` + r + `<span style="color: ${Y.annotation}; opacity: 0.75">}</span>`, u = e + 1, d = c.indexOf("{", u);
|
|
1746
|
+
}
|
|
1747
|
+
l += J(c.slice(u));
|
|
1748
|
+
let f = c.includes("{") && c.includes("}"), p = `h${i}`, m = "#".repeat(i), h = f ? `color: ${Y.marker}; opacity: 0.8` : "";
|
|
1749
|
+
n += `<${p} style="margin: 0; font-weight: 600;"><span style="${h}">${m}</span> ${l}</${p}>`, r = s;
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
if (i === "-" || i === "*") {
|
|
1754
|
+
let t = r > 0 ? e[r - 1] : "\n";
|
|
1755
|
+
if ((t === "\n" || t === "\r" || t === " " || t === " ") && e[r + 1] === " ") {
|
|
1756
|
+
let t = X(e, r + 2) ? `color: ${Y.marker}; opacity: 0.85` : "";
|
|
1757
|
+
n += `<span style="${t}">${J(i)}</span>`, r++;
|
|
1758
|
+
continue;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
if (i === ">") {
|
|
1762
|
+
let t = r > 0 ? e[r - 1] : "\n";
|
|
1763
|
+
if ((t === "\n" || t === "\r" || t === " " || t === " ") && e[r + 1] === " ") {
|
|
1764
|
+
let t = X(e, r + 2) ? `color: ${Y.marker}; opacity: 0.85` : "";
|
|
1765
|
+
n += `<span style="${t}">${J(i)}</span>`, r++;
|
|
1766
|
+
continue;
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
n += J(i), r++;
|
|
1770
|
+
}
|
|
1771
|
+
return n;
|
|
1546
1772
|
}
|
|
1547
1773
|
//#endregion
|
|
1548
|
-
export { e as DEFAULT_CONTEXT, d as DataFactory, h as expandIRI,
|
|
1774
|
+
export { e as DEFAULT_CONTEXT, d as DataFactory, h as expandIRI, Ve as generate, He as generateNode, Q as getIRIColor, p as hash, yt as hashIRI, St as highlightMDLD, f as locate, ze as merge, I as parse, _ as parseSemanticBlock, Je as render, g as shortenIRI };
|