@lblod/graph-rdfa-processor 2.1.1 → 2.1.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/bug2.html +3247 -0
- package/dist/rdfa-graph.js +1 -1
- package/dist/rdfa-processor.js +0 -4
- package/package.json +1 -1
- package/src/rdfa-graph.js +9 -9
- package/src/rdfa-processor.js +1 -3
- package/test/test.js +3 -3
package/dist/rdfa-graph.js
CHANGED
package/dist/rdfa-processor.js
CHANGED
@@ -885,10 +885,6 @@ function (_URIResolver) {
|
|
885
885
|
} else {
|
886
886
|
content = current.textContent;
|
887
887
|
|
888
|
-
if (content.includes("\\")) {
|
889
|
-
content = content.replaceAll("\\", "\\\\");
|
890
|
-
}
|
891
|
-
|
892
888
|
if (this.inHTMLMode && current.localName == "time") {
|
893
889
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
894
890
|
}
|
package/package.json
CHANGED
package/src/rdfa-graph.js
CHANGED
@@ -4,10 +4,10 @@ export class RDFaGraph {
|
|
4
4
|
constructor() {
|
5
5
|
var dataContext = this;
|
6
6
|
this.curieParser = {
|
7
|
-
trim: function(str) {
|
7
|
+
trim: function (str) {
|
8
8
|
return str.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
|
9
9
|
},
|
10
|
-
parse: function(value, resolve) {
|
10
|
+
parse: function (value, resolve) {
|
11
11
|
value = this.trim(value);
|
12
12
|
if (value.charAt(0) == "[" && value.charAt(value.length - 1) == "]") {
|
13
13
|
value = value.substring(1, value.length - 1);
|
@@ -34,19 +34,19 @@ export class RDFaGraph {
|
|
34
34
|
},
|
35
35
|
};
|
36
36
|
this.base = null;
|
37
|
-
this.toString = function(requestOptions) {
|
37
|
+
this.toString = function (requestOptions) {
|
38
38
|
var options =
|
39
39
|
requestOptions && requestOptions.shorten
|
40
40
|
? { graph: this, shorten: true, prefixesUsed: {} }
|
41
41
|
: null;
|
42
42
|
if (requestOptions && requestOptions.blankNodePrefix) {
|
43
|
-
options.filterBlankNode = function(id) {
|
43
|
+
options.filterBlankNode = function (id) {
|
44
44
|
return "_:" + requestOptions.blankNodePrefix + id.substring(2);
|
45
45
|
};
|
46
46
|
}
|
47
47
|
if (requestOptions && requestOptions.numericalBlankNodePrefix) {
|
48
48
|
var onlyNumbers = /^[0-9]+$/;
|
49
|
-
options.filterBlankNode = function(id) {
|
49
|
+
options.filterBlankNode = function (id) {
|
50
50
|
var label = id.substring(2);
|
51
51
|
return onlyNumbers.test(label)
|
52
52
|
? "_:" + requestOptions.numericalBlankNodePrefix + label
|
@@ -72,7 +72,7 @@ export class RDFaGraph {
|
|
72
72
|
return prolog.length == 0 ? s : prolog + "\n" + s;
|
73
73
|
};
|
74
74
|
this.blankNodeCounter = 0;
|
75
|
-
this.clear = function() {
|
75
|
+
this.clear = function () {
|
76
76
|
this.subjects = {};
|
77
77
|
this.prefixes = {};
|
78
78
|
this.terms = {};
|
@@ -130,7 +130,7 @@ export class RDFaGraph {
|
|
130
130
|
Object.defineProperty(this, "tripleCount", {
|
131
131
|
enumerable: true,
|
132
132
|
configurable: false,
|
133
|
-
get: function() {
|
133
|
+
get: function () {
|
134
134
|
var count = 0;
|
135
135
|
for (var s in this.subjects) {
|
136
136
|
var snode = this.subjects[s];
|
@@ -307,7 +307,7 @@ export class RDFaSubject {
|
|
307
307
|
s += " " + this.predicates[predicate].toString(options);
|
308
308
|
}
|
309
309
|
s += " .";
|
310
|
-
return s;
|
310
|
+
return s.replaceAll("\\", "\\\\");
|
311
311
|
}
|
312
312
|
|
313
313
|
toObject() {
|
@@ -498,7 +498,7 @@ export class RDFaPredicate {
|
|
498
498
|
}
|
499
499
|
}
|
500
500
|
|
501
|
-
RDFaPredicate.getPrefixMap = function(e) {
|
501
|
+
RDFaPredicate.getPrefixMap = function (e) {
|
502
502
|
var prefixMap = {};
|
503
503
|
while (e.attributes) {
|
504
504
|
for (var i = 0; i < e.attributes.length; i++) {
|
package/src/rdfa-processor.js
CHANGED
@@ -913,9 +913,7 @@ export default class RDFaProcessor extends URIResolver {
|
|
913
913
|
content = typedResource;
|
914
914
|
} else {
|
915
915
|
content = current.textContent;
|
916
|
-
|
917
|
-
content = content.replaceAll("\\", "\\\\");
|
918
|
-
}
|
916
|
+
|
919
917
|
if (this.inHTMLMode && current.localName == "time") {
|
920
918
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
921
919
|
}
|
package/test/test.js
CHANGED
@@ -23,8 +23,8 @@ describe("getRDFaGraph", function () {
|
|
23
23
|
assert.equal(graph.toString(), expected);
|
24
24
|
});
|
25
25
|
|
26
|
-
it("whatever", () => {
|
27
|
-
let ht = readFileSync("./
|
26
|
+
it.only("whatever", () => {
|
27
|
+
let ht = readFileSync("./bug2.html");
|
28
28
|
let { document } = jsdom(ht).defaultView.window;
|
29
29
|
|
30
30
|
let graph = getRDFaGraph(document, {
|
@@ -37,7 +37,7 @@ describe("getRDFaGraph", function () {
|
|
37
37
|
},
|
38
38
|
],
|
39
39
|
});
|
40
|
-
writeFileSync("/tmp/x.
|
40
|
+
writeFileSync("/tmp/x.ttl", graph.toString(), "utf8");
|
41
41
|
});
|
42
42
|
|
43
43
|
it("should getRDFaGraph from a node", function () {
|