@lblod/graph-rdfa-processor 2.1.3 → 2.1.4

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.
@@ -556,7 +556,7 @@ function () {
556
556
  var l = this.objects[i].value.toString();
557
557
 
558
558
  if (l.indexOf("\n") >= 0 || l.indexOf("\r") >= 0) {
559
- s += '"""' + l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"""/g, '\\"\\"\\"') + '"""';
559
+ s += '"""' + l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"/g, '\\"') + '"""';
560
560
  } else {
561
561
  s += '"' + l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"/g, '\\"') + '"';
562
562
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/graph-rdfa-processor",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Green turtle GraphRdfaProcessor extracted and available as a commonJS module",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
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];
@@ -480,12 +480,11 @@ export class RDFaPredicate {
480
480
  }
481
481
  } else {
482
482
  var l = this.objects[i].value.toString();
483
+
483
484
  if (l.indexOf("\n") >= 0 || l.indexOf("\r") >= 0) {
484
485
  s +=
485
486
  '"""' +
486
- l
487
- .replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\")
488
- .replace(/"""/g, '\\"\\"\\"') +
487
+ l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"/g, '\\"') +
489
488
  '"""';
490
489
  } else {
491
490
  s +=
@@ -507,7 +506,7 @@ export class RDFaPredicate {
507
506
  }
508
507
  }
509
508
 
510
- RDFaPredicate.getPrefixMap = function (e) {
509
+ RDFaPredicate.getPrefixMap = function(e) {
511
510
  var prefixMap = {};
512
511
  while (e.attributes) {
513
512
  for (var i = 0; i < e.attributes.length; i++) {
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.only("whatever", () => {
27
- let ht = readFileSync("./bug.html");
26
+ it("whatever", () => {
27
+ let ht = readFileSync("./bug4.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.ttl", 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",