blake-regalia / graphy.js

A collection of RDF libraries for JavaScript
https://graphy.link/
ISC License
161 stars 3 forks source link

Patch for the @graphy/content.ttl.write module that adds customization of indentation style #62

Open alik-kirillovich opened 1 year ago

alik-kirillovich commented 1 year ago

I developed a small patch for the @graphy/content.ttl.write module, that adds customization of the indentation style of the produced Turtle code.

In the Turtle code generated by the original module, the first predicate-objects pair of every subject is on one line with this subject, and any predicate-objects pair is written in one line. When an RDF graph contains long object lists, the generated Turtle code is difficult to read.

For example, in the following Turtle code, the objects of the skos:hasTopConcept predicate either don't fit to the window or break the line thus breaking the code formatting:

<http://example.com/my-concept-scheme> rdf:type skos:Concept, lime:Lexicon ;
    rdfs:label "My concept scheme"@en, "Mi esquema de conceptos"@es, "Моя концептуальная схема"@ru ;
    skos:hasTopConcept <http://example.com/my-concept-scheme/concept1>, <http://example.com/my-concept-scheme/concept2>, <http://example.com/my-concept-scheme/concept3>, <http://example.com/my-concept-scheme/concept4>, <http://example.com/my-concept-scheme/concept5>, <http://example.com/my-concept-scheme/concept6>, <http://example.com/my-concept-scheme/concept7>, <http://example.com/my-concept-scheme/concept8>, <http://example.com/my-concept-scheme/concept9>, <http://example.com/my-concept-scheme/concept10> ;
    dc:creator <http://example.com/john-smith> ;
    dc:language "en" .

The patch allows this code to be formatted e.g. in this, more readable, way:

<http://example.com/my-concept-scheme>
    rdf:type
        skos:Concept,
        lime:Lexicon ;
    rdfs:label
        "My concept scheme"@en,
        "Mi esquema de conceptos"@es,
        "Моя концептуальная схема"@ru ;
    skos:hasTopConcept
        <http://example.com/my-concept-scheme/concept1>,
        <http://example.com/my-concept-scheme/concept2>,
        <http://example.com/my-concept-scheme/concept3>,
        <http://example.com/my-concept-scheme/concept4>,
        <http://example.com/my-concept-scheme/concept5>,
        <http://example.com/my-concept-scheme/concept6>,
        <http://example.com/my-concept-scheme/concept7>,
        <http://example.com/my-concept-scheme/concept8>,
        <http://example.com/my-concept-scheme/concept9>,
        <http://example.com/my-concept-scheme/concept10> ;
    dc:creator
        <http://example.com/john-smith> ;
    dc:language "en" .

The patch (with a detailed description and examples) can be found at: https://github.com/alik-kirillovich/graphy.content.ttl.write-patch.

I tried to integrate the patch into @graphy/content.ttl.write by sending a usual pull request, but I couldn't find the GitHub repository of this module. Could you please see the patch, and if you approve it, integrate it to the @graphy/content.ttl.write?