Skip to content

Commit 79a5118

Browse files
committed
Add rdfstar option
1 parent de137f8 commit 79a5118

File tree

7 files changed

+14930
-948
lines changed

7 files changed

+14930
-948
lines changed

lib/JsonLdParser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,4 +637,9 @@ export interface IJsonLdParserOptions {
637637
* This is useful when parsing large contexts that are known to be valid.
638638
*/
639639
skipContextValidation?: boolean;
640+
/**
641+
* If nested triples should be parsed according to the JSON-LD star specification.
642+
* Defaults to true
643+
*/
644+
rdfstar?: boolean;
640645
}

lib/ParsingContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class ParsingContext {
3636
public readonly rdfDirection?: 'i18n-datatype' | 'compound-literal';
3737
public readonly normalizeLanguageTags?: boolean;
3838
public readonly streamingProfileAllowOutOfOrderPlainType?: boolean;
39+
public readonly rdfstar: boolean;
3940

4041
// Stack of indicating if a depth has been touched.
4142
public readonly processingStack: boolean[];
@@ -92,6 +93,7 @@ export class ParsingContext {
9293
this.rdfDirection = options.rdfDirection;
9394
this.normalizeLanguageTags = options.normalizeLanguageTags;
9495
this.streamingProfileAllowOutOfOrderPlainType = options.streamingProfileAllowOutOfOrderPlainType;
96+
this.rdfstar = options.rdfstar !== false;
9597

9698
this.topLevelProperties = false;
9799
this.activeProcessingMode = parseFloat(this.processingMode);

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"jest-rdf": "^1.7.0",
5858
"manual-git-changelog": "^1.0.1",
5959
"pre-commit": "^1.2.2",
60-
"rdf-test-suite": "^1.13.4",
60+
"rdf-test-suite": "^1.20.0",
6161
"streamify-string": "^1.0.1",
6262
"ts-jest": "^28.0.0",
6363
"ts-loader": "^9.3.1",
@@ -100,12 +100,14 @@
100100
"validate": "npm ls",
101101
"prepare": "npm run build",
102102
"version": "manual-git-changelog onversion",
103-
"spec": "npm run spec-tordf && npm run spec-stream-tordf",
104-
"spec-earl": "npm run spec-earl-tordf && npm run spec-earl-stream-tordf",
103+
"spec": "npm run spec-tordf && npm run spec-stream-tordf && npm run spec-star-tordf",
104+
"spec-earl": "npm run spec-earl-tordf && npm run spec-earl-stream-tordf && npm run spec-earl-star-tordf",
105105
"spec-tordf": "rdf-test-suite spec/parser.js https://w3c.github.io/json-ld-api/tests/toRdf-manifest.jsonld -c .rdf-test-suite-cache/ -e",
106106
"spec-earl-tordf": "rdf-test-suite spec/parser.js https://w3c.github.io/json-ld-api/tests/toRdf-manifest.jsonld -c .rdf-test-suite-cache/ -o earl -p spec/earl-meta.json > spec/earl-tordf.ttl",
107107
"spec-stream-tordf": "rdf-test-suite spec/parser.js -i '{ \"streamingProfile\": true }' https://w3c.github.io/json-ld-streaming/tests/stream-toRdf-manifest.jsonld -c .rdf-test-suite-cache/",
108108
"spec-earl-stream-tordf": "rdf-test-suite spec/parser.js -i '{ \"streamingProfile\": true }' https://w3c.github.io/json-ld-streaming/tests/stream-toRdf-manifest.jsonld -c .rdf-test-suite-cache/ -o earl -p spec/earl-meta.json > spec/earl-stream-tordf.ttl",
109+
"spec-star-tordf": "rdf-test-suite spec/parser.js https://json-ld.github.io/json-ld-star/tests/toRdf-manifest.jsonld -c .rdf-test-suite-cache/ -e",
110+
"spec-earl-star-tordf": "rdf-test-suite spec/parser.js https://json-ld.github.io/json-ld-star/tests/toRdf-manifest.jsonld -c .rdf-test-suite-cache/ -o earl -p spec/earl-meta.json > spec/earl-star-tordf.ttl",
109111
"spec-clean": "rm -r .rdf-test-suite-cache/"
110112
},
111113
"sideEffects": false

spec/earl-stream-tordf.ttl

Lines changed: 7280 additions & 0 deletions
Large diffs are not rendered by default.

spec/earl-tordf.ttl

Lines changed: 6830 additions & 0 deletions
Large diffs are not rendered by default.

spec/parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
return Promise.reject(
88
new ErrorSkipped(`Test with processing mode ${options.processingMode} was skipped, only 1.0 is supported.`));
99
}
10-
if (options.specVersion && options.specVersion !== '1.1') {
10+
if (options.specVersion && options.specVersion !== '1.1' && options.specVersion !== 'star') {
1111
return Promise.reject(
1212
new ErrorSkipped(`Test with spec version ${options.specVersion} was skipped, only 1.1 is supported.`));
1313
}

0 commit comments

Comments
 (0)