Symptom
Today's Turtle output (e.g. https://test.solid.social/profile/card.jsonld with Accept: text/turtle) packs ; and . directly against the previous token:
<...#me> a foaf:Person, schema:Person;
foaf:name "test";
pim:storage <https://test.solid.social/>.
<...#nostr-key-1> a <https://www.w3.org/ns/cid/v1#Multikey>;
<https://www.w3.org/ns/cid/v1#controller> <...#me>;
<https://www.w3.org/ns/cid/v1#publicKeyMultibase> "fe70102de7ec...".
A more typical/canonical-leaning style separates the statement terminators from the previous token by a space:
<...#me> a foaf:Person, schema:Person ;
foaf:name "test" ;
pim:storage <https://test.solid.social/> .
<...#nostr-key-1> a <https://www.w3.org/ns/cid/v1#Multikey> ;
<https://www.w3.org/ns/cid/v1#controller> <...#me> ;
<https://www.w3.org/ns/cid/v1#publicKeyMultibase> "fe70102de7ec..." .
Status of "canonical form" for Turtle
There is no formally W3C-defined canonical Turtle. RDF Dataset Canonicalization (RDC-1.0) operates on N-Quads, not Turtle. So strictly speaking, both forms are spec-conformant Turtle.
However, the spaced form is widely treated as the "pretty" / preferred style:
- W3C Turtle 1.1 spec examples consistently use a space before
; and .
- Apache Jena's RIOT Turtle writer emits the spaced form
- Most hand-written Turtle in the Solid / Linked Data ecosystem uses the spaced form
- It improves human readability (the terminator is visually separable from the value) and reduces ambiguity for naive line-counters
The current N3.js default packs them. JSS uses N3.js (new Writer({...})) — see src/rdf/turtle.js:72.
What to investigate
- Whether N3.js's
Writer exposes a config option (spaceBeforeTerminator, pretty, etc.) for this. If it does, flip the option in our usage.
- If not, evaluate whether a small post-processing pass on the writer's output (regex
/([^\s])([;.])(\s|$)/g → $1 $2$3, with care around literals containing ; or .) is the right approach. Note the literal-safety concern is real — "foo;bar" must not become "foo ;bar".
- Check whether any existing test depends on the no-space form (it shouldn't — Turtle parsers must accept both — but a snapshot-style test might).
Acceptance
After the change, curl -H 'Accept: text/turtle' <profile> emits:
- A space before every
; that terminates a predicate-list continuation
- A space before every
. that terminates a triple
- Existing parsers (N3.js, Jena, rdflib, etc.) round-trip unchanged
- Existing JSS Turtle tests still pass (or are minimally updated to match the new style)
Refs
Symptom
Today's Turtle output (e.g.
https://test.solid.social/profile/card.jsonldwithAccept: text/turtle) packs;and.directly against the previous token:A more typical/canonical-leaning style separates the statement terminators from the previous token by a space:
Status of "canonical form" for Turtle
There is no formally W3C-defined canonical Turtle. RDF Dataset Canonicalization (RDC-1.0) operates on N-Quads, not Turtle. So strictly speaking, both forms are spec-conformant Turtle.
However, the spaced form is widely treated as the "pretty" / preferred style:
;and.The current N3.js default packs them. JSS uses N3.js (
new Writer({...})) — seesrc/rdf/turtle.js:72.What to investigate
Writerexposes a config option (spaceBeforeTerminator,pretty, etc.) for this. If it does, flip the option in our usage./([^\s])([;.])(\s|$)/g→$1 $2$3, with care around literals containing;or.) is the right approach. Note the literal-safety concern is real —"foo;bar"must not become"foo ;bar".Acceptance
After the change,
curl -H 'Accept: text/turtle' <profile>emits:;that terminates a predicate-list continuation.that terminates a tripleRefs
src/rdf/turtle.js:72@type: '@json'), rdf/turtle: nested verificationMethod objects dropped from Turtle output #415/rdf/turtle: accept JSON-LD id/type aliases on nested objects (#415) #416 (nested VM), Profile emits bare 'Multikey' type — resolves to <pod>/profile/Multikey instead of cid:Multikey #417 (Multikey class IRI) — all about making JSS's Turtle output spec-correct + interop-friendly