The serializer to NQuads (and turtle and others) uses the stringToN3 function to convert the value of a string literal to a safe string in the output syntax.
However, the code uses the triple quote """ as delimiter for strings that contain a newline or a quote " character:
The serializer to NQuads (and turtle and others) uses the
stringToN3
function to convert the value of a string literal to a safe string in the output syntax.However, the code uses the triple quote
"""
as delimiter for strings that contain a newline or a quote"
character:https://github.com/linkeddata/rdflib.js/blob/cfc0f8c437d7872d76dc384d686c28d5d6100e35/src/serializer.js#L584-L589
This is not a valid serialization for NQuads, see the literal production grammar:
https://www.w3.org/TR/n-quads/#grammar-production-literal
The
stringToN3
function should use the normal escaping using a backslash, i.e.\n
and\"
.