@lblod/graph-rdfa-processor 2.1.0 → 2.1.1
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/bug.html +2617 -0
- package/dist/rdfa-processor.js +4 -0
- package/package.json +1 -1
- package/src/rdfa-processor.js +25 -22
- package/test/test.js +5 -5
package/dist/rdfa-processor.js
CHANGED
@@ -885,6 +885,10 @@ function (_URIResolver) {
|
|
885
885
|
} else {
|
886
886
|
content = current.textContent;
|
887
887
|
|
888
|
+
if (content.includes("\\")) {
|
889
|
+
content = content.replaceAll("\\", "\\\\");
|
890
|
+
}
|
891
|
+
|
888
892
|
if (this.inHTMLMode && current.localName == "time") {
|
889
893
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
890
894
|
}
|
package/package.json
CHANGED
package/src/rdfa-processor.js
CHANGED
@@ -208,9 +208,9 @@ export default class RDFaProcessor extends URIResolver {
|
|
208
208
|
if (node.ownerDocument.doctype) {
|
209
209
|
if (
|
210
210
|
node.ownerDocument.doctype.publicId ==
|
211
|
-
|
211
|
+
"-//W3C//DTD XHTML+RDFa 1.0//EN" &&
|
212
212
|
node.ownerDocument.doctype.systemId ==
|
213
|
-
|
213
|
+
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"
|
214
214
|
) {
|
215
215
|
console.log(
|
216
216
|
"WARNING: RDF 1.0 is not supported. Defaulting to HTML5 mode.",
|
@@ -218,9 +218,9 @@ export default class RDFaProcessor extends URIResolver {
|
|
218
218
|
this.setHTMLContext();
|
219
219
|
} else if (
|
220
220
|
node.ownerDocument.doctype.publicId ==
|
221
|
-
|
221
|
+
"-//W3C//DTD XHTML+RDFa 1.1//EN" &&
|
222
222
|
node.ownerDocument.doctype.systemId ==
|
223
|
-
|
223
|
+
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd"
|
224
224
|
) {
|
225
225
|
this.setXHTMLContext();
|
226
226
|
} else {
|
@@ -329,11 +329,11 @@ export default class RDFaProcessor extends URIResolver {
|
|
329
329
|
"http://www.w3.org/1999/xhtml/vocab#transformation";
|
330
330
|
}
|
331
331
|
|
332
|
-
init() {
|
332
|
+
init() {}
|
333
333
|
|
334
|
-
newSubjectOrigin(origin, subject) {
|
334
|
+
newSubjectOrigin(origin, subject) {}
|
335
335
|
|
336
|
-
addTriple(origin, subject, predicate, object) {
|
336
|
+
addTriple(origin, subject, predicate, object) {}
|
337
337
|
|
338
338
|
process(node, options) {
|
339
339
|
if (node.nodeType == Node.DOCUMENT_NODE) {
|
@@ -344,7 +344,7 @@ export default class RDFaProcessor extends URIResolver {
|
|
344
344
|
}
|
345
345
|
var queue = [];
|
346
346
|
// Fix for Firefox that includes the hash in the base URI
|
347
|
-
var removeHash = function(baseURI) {
|
347
|
+
var removeHash = function (baseURI) {
|
348
348
|
var hash = baseURI.indexOf("#");
|
349
349
|
if (hash >= 0) {
|
350
350
|
baseURI = baseURI.substring(0, hash);
|
@@ -864,18 +864,18 @@ export default class RDFaProcessor extends URIResolver {
|
|
864
864
|
datatypeAtt.value == ""
|
865
865
|
? RDFaProcessor.PlainLiteralURI
|
866
866
|
: this.parseTermOrCURIEOrAbsURI(
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
867
|
+
datatypeAtt.value,
|
868
|
+
vocabulary,
|
869
|
+
context.terms,
|
870
|
+
prefixes,
|
871
|
+
base,
|
872
|
+
);
|
873
873
|
if (datetimeAtt && !contentAtt) {
|
874
874
|
content = datetimeAtt.value;
|
875
875
|
} else {
|
876
876
|
content =
|
877
877
|
datatype == RDFaProcessor.XMLLiteralURI ||
|
878
|
-
|
878
|
+
datatype == RDFaProcessor.HTMLLiteralURI
|
879
879
|
? null
|
880
880
|
: contentAtt
|
881
881
|
? contentAtt.value
|
@@ -913,6 +913,9 @@ export default class RDFaProcessor extends URIResolver {
|
|
913
913
|
content = typedResource;
|
914
914
|
} else {
|
915
915
|
content = current.textContent;
|
916
|
+
if (content.includes("\\")) {
|
917
|
+
content = content.replaceAll("\\", "\\\\");
|
918
|
+
}
|
916
919
|
if (this.inHTMLMode && current.localName == "time") {
|
917
920
|
datatype = RDFaProcessor.deriveDateTimeType(content);
|
918
921
|
}
|
@@ -942,10 +945,10 @@ export default class RDFaProcessor extends URIResolver {
|
|
942
945
|
datatype == RDFaProcessor.HTMLLiteralURI
|
943
946
|
? { type: datatype, value: current.childNodes }
|
944
947
|
: {
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
948
|
+
type: datatype ? datatype : RDFaProcessor.PlainLiteralURI,
|
949
|
+
value: content,
|
950
|
+
language: language,
|
951
|
+
},
|
949
952
|
);
|
950
953
|
} else {
|
951
954
|
if (
|
@@ -1072,7 +1075,7 @@ export default class RDFaProcessor extends URIResolver {
|
|
1072
1075
|
}
|
1073
1076
|
}
|
1074
1077
|
|
1075
|
-
copyProperties() {
|
1078
|
+
copyProperties() {}
|
1076
1079
|
|
1077
1080
|
push(parent, subject) {
|
1078
1081
|
return {
|
@@ -1107,7 +1110,7 @@ RDFaProcessor.NCNAME = new RegExp(
|
|
1107
1110
|
"^" + RDFaProcessor.nameStartChar + RDFaProcessor.nameChar + "*$",
|
1108
1111
|
);
|
1109
1112
|
|
1110
|
-
RDFaProcessor.trim = function(str) {
|
1113
|
+
RDFaProcessor.trim = function (str) {
|
1111
1114
|
return str.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
|
1112
1115
|
};
|
1113
1116
|
|
@@ -1143,7 +1146,7 @@ RDFaProcessor.dateTimeTypes = [
|
|
1143
1146
|
},
|
1144
1147
|
];
|
1145
1148
|
|
1146
|
-
RDFaProcessor.deriveDateTimeType = function(value) {
|
1149
|
+
RDFaProcessor.deriveDateTimeType = function (value) {
|
1147
1150
|
for (var i = 0; i < RDFaProcessor.dateTimeTypes.length; i++) {
|
1148
1151
|
//console.log("Checking "+value+" against "+RDFaProcessor.dateTimeTypes[i].type);
|
1149
1152
|
var matched = RDFaProcessor.dateTimeTypes[i].pattern.exec(value);
|
package/test/test.js
CHANGED
@@ -2,7 +2,7 @@ import { jsdom } from "jsdom";
|
|
2
2
|
import assert from "assert";
|
3
3
|
import getRDFaGraph from "../src";
|
4
4
|
import { readFileSync, writeFileSync } from "fs";
|
5
|
-
describe("getRDFaGraph", function() {
|
5
|
+
describe("getRDFaGraph", function () {
|
6
6
|
let html = `<div typeof="rdfs:Class" resource="http://schema.org/CreativeWork">
|
7
7
|
<span class="h" property="rdfs:label">CreativeWork</span>
|
8
8
|
<span property="rdfs:comment">The most generic kind of creative work, including books, movies, photographs, software programs, etc.</span>
|
@@ -17,14 +17,14 @@ describe("getRDFaGraph", function() {
|
|
17
17
|
<http://purl.org/dc/terms/source> <http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#source_rNews> .
|
18
18
|
`;
|
19
19
|
|
20
|
-
it("should getRDFaGraph from a document", function() {
|
20
|
+
it("should getRDFaGraph from a document", function () {
|
21
21
|
let { document } = jsdom(html).defaultView.window;
|
22
22
|
let graph = getRDFaGraph(document, { baseURI: "http://localhost" });
|
23
23
|
assert.equal(graph.toString(), expected);
|
24
24
|
});
|
25
25
|
|
26
|
-
it
|
27
|
-
let ht = readFileSync("./
|
26
|
+
it("whatever", () => {
|
27
|
+
let ht = readFileSync("./bug.html");
|
28
28
|
let { document } = jsdom(ht).defaultView.window;
|
29
29
|
|
30
30
|
let graph = getRDFaGraph(document, {
|
@@ -40,7 +40,7 @@ describe("getRDFaGraph", function() {
|
|
40
40
|
writeFileSync("/tmp/x.out", graph.toString(), "utf8");
|
41
41
|
});
|
42
42
|
|
43
|
-
it("should getRDFaGraph from a node", function() {
|
43
|
+
it("should getRDFaGraph from a node", function () {
|
44
44
|
let { document } = jsdom(html).defaultView.window;
|
45
45
|
let graph = getRDFaGraph(document.getElementsByTagName("div")[0], {
|
46
46
|
baseURI: "http://localhost",
|