metanorma / metanorma-ogc

Metanorma processor for OGC documents
https://www.metanorma.com
BSD 2-Clause "Simplified" License
2 stars 3 forks source link

How can we add Turtle and SPARQL source code highlighting? #632

Closed gbuehler closed 7 months ago

gbuehler commented 9 months ago

The new version of OGC's GeoSPARQL Standard has many source code blocks of turtle and SPARQL snippets. In a previous version, which was done in straight Asciidoc and produced with Asciidoctor, the HTML results look like this:

Screenshot 2024-02-13 at 11 06 01 AM

Using the source code syntax for Metanorma:

[ source,turtle] or [source,sparql] the results are not very visual:

Screenshot 2024-02-13 at 11 05 20 AM

If I change the language to something not recognized, I can get the <pre>, but not the highlighting:

Screenshot 2024-02-13 at 11 05 33 AM

I have looked up Rouge and it seems to handle both of these languages, but I can't figure out how to get them to work.

opoudjis commented 9 months ago

[source,turtle] and [source,sparql] should indeed be working if they are supported in Rouge. I will investigate. If it works as pre without a language, but loses formatting with those languages, that suggests a bug—some Rouge output that Metanorma is not expecting. But won't know until I have some dedicated time to check.

opoudjis commented 9 months ago

I can't replicate:

Screenshot 2024-02-17 at 14 21 33

with Asciidoc source:

== Clause

[source,turtle]
----
@prefix geo: <http://www.opengis.net/ont/geosparql#> .
@prefix my: <http://example.org/ApplicationSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sf: <http://www.opengis.net/ont/sf#> .

my:PlaceOfInterest a rdfs:Class ;
    rdfs:subClassOf geo:Feature .
----

[source,sparql]
----
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
    ASK
    WHERE {
        ?g geo:hasMetricPerimeterLength ?p ;
           geo:dimension ?d .

        FILTER (?d < 2)}
----

Compiling https://github.com/opengeospatial/ogc-geosparql.git locally...

opoudjis commented 9 months ago

I've compiled the site, and it indents correctly, but does not introduce colouring—or rather, it introduces only generic colouring:

Screenshot 2024-02-17 at 14 29 35

The green in quotes is what you get when Rouge has no idea what the language is, and it falls back on generic. I suspect that's what's happening with the Turtle too...

opoudjis commented 9 months ago

The source I got from https://github.com/opengeospatial/ogc-geosparql has [source,RDF] and [source,shell], not [source,turtle] or [source,sparql].

Changing the first two examples to the correct language markup is giving me correct syntax colouring.

Screenshot 2024-02-17 at 14 40 38

I'm afraid I can't help further here. The issue you've just had with a PDF update in https://github.com/metanorma/metanorma-ogc/issues/628 suggests that your Docker has out of date code, and you will need to scrutinise which version of metanorma-ogc and docker is being used. The mangling of indentation also suggests out of date code. But that is outside my domain.

I can only say that debugging https://github.com/metanorma/metanorma-ogc/issues/628 will likely debug this as well. I'm moving this issue to pending, please confirm compilation after Monday release.

opoudjis commented 9 months ago

@gbuehler Release should now be out, could you please let me know current behaviour, and what version of Metanorma your Docker instance is running?

ghobona commented 8 months ago

Discussed 2024-03-19

Greg will try deleting the cached images and re-pulling the latest docker image.

ghobona commented 7 months ago

@gbuehler Did deleting the cached images and re-pulling the latest docker image work?

gbuehler commented 7 months ago

Yes, this now works. Sorry, I missed this.