Skip to content

Commit e63baf5

Browse files
committed
Merge pull request #123 from jindrichmynarz/nquads-allow-comments
Nquads allow comments, fixes
2 parents d920c0f + 8c0dcfe commit e63baf5

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

js/jsonld.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6831,7 +6831,7 @@ function _parseNQuads(input) {
68316831
var datatype = '(?:\\^\\^' + iri + ')';
68326832
var language = '(?:@([a-z]+(?:-[a-z0-9]+)*))';
68336833
var literal = '(?:' + plain + '(?:' + datatype + '|' + language + ')?)';
6834-
var comment = '(?:#[^$]*)?';
6834+
var comment = '(?:#.*)?';
68356835
var ws = '[ \\t]+';
68366836
var wso = '[ \\t]*';
68376837
var eoln = /(?:\r\n)|(?:\n)|(?:\r)/g;

tests/fromRdf-0001-in.nq

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<http://example.com/Subj1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/Type> .
2+
# $5 comment
3+
<http://example.com/Subj1> <http://example.com/prop1> <http://example.com/Obj1> .
4+
<http://example.com/Subj1> <http://example.com/prop2> "Plain" . # Another comment
5+
<http://example.com/Subj1> <http://example.com/prop2> "2012-05-12"^^<http://www.w3.org/2001/XMLSchema#date> .
6+
<http://example.com/Subj1> <http://example.com/prop2> "English"@en .

tests/fromRdf-0001-out.jsonld

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"@id": "http://example.com/Subj1",
4+
"@type": ["http://example.com/Type"],
5+
"http://example.com/prop1": [{"@id": "http://example.com/Obj1"}],
6+
"http://example.com/prop2": [
7+
{"@value": "Plain"},
8+
{"@value": "2012-05-12", "@type": "http://www.w3.org/2001/XMLSchema#date"},
9+
{"@value": "English", "@language": "en"}
10+
]
11+
}
12+
]

tests/manifest.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,12 @@
4141
"name": "follow redirect",
4242
"input": "remote-0006-in.jsonld",
4343
"expect": "remote-0006-out.jsonld"
44+
}, {
45+
"@id": "#t0007",
46+
"@type": ["jld:PositiveEvaluationTest", "jld:FromRDFTest"],
47+
"name": "allow comments in N-Quads",
48+
"purpose": "RDF serialized in N-Quads may contain comments",
49+
"input": "fromRdf-0001-in.nq",
50+
"expect": "fromRdf-0001-out.jsonld"
4451
}]
4552
}

0 commit comments

Comments
 (0)