Skip to content

Commit

Permalink
Support serialization of literal base directions
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jan 14, 2025
1 parent f94d02a commit 88019d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/N3Writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,9 @@ export default class N3Writer {
value = value.replace(escapeAll, characterReplacer);

// Write a language-tagged literal
const direction = literal.direction ? `--${literal.direction}` : '';
if (literal.language)
return `"${value}"@${literal.language}`;
return `"${value}"@${literal.language}${direction}`;

// Write dedicated literals per data type
if (this._lineMode) {
Expand Down
6 changes: 6 additions & 0 deletions test/N3Writer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ describe('Writer', () => {
'<a> <b> "cde"@en-us.\n'),
);

it(
'should serialize a literal with a language and direction',
shouldSerialize(['a', 'b', '"cde"@en-us--ltr'],
'<a> <b> "cde"@en-us--ltr.\n'),
);

// e.g. http://vocab.getty.edu/aat/300264727.ttl
it(
'should serialize a literal with an artificial language',
Expand Down

0 comments on commit 88019d9

Please sign in to comment.