Widoco icon indicating copy to clipboard operation
Widoco copied to clipboard

Codeblock highlight for SPARQL and turtle

Open vemonet opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

When providing example code blocks in turtle or SPARQL the code is not hightlighted which makes it harder to read.

Having built-in highlight for common RDF languages such as SPARQL or turtle would make the examples provided in markdown much easier to read for users

Describe the solution you'd like

I am not sure of how the markdown is processed by widoco (is it done at build time by java?)

The highlight.js npm package would make it possible to add hightlighting for RDF languages, they have support for turtle and SPARQL: https://github.com/highlightjs/highlightjs-turtle

But we would also need to make it work with the markdown processor used by widoco

Describe alternatives you've considered

I did not looked into it deeply but maybe there is already a way for us to inject a npm dependency and a small JS script to enable highlighting without touching the widoco code itself?

Additional context

You might want to make this optional (opt-in with a flag, e.g. --highlightjs), so that only people who uses it. Another option would be to check for the presence of code blocks tagged with sparql or ttl/turtle in provided markdown code and only add the dependencies when such tags are detected

vemonet avatar May 15 '24 10:05 vemonet

Hi @vemonet, the markdown is processed through a javascript library, so your solution makes sense to me. Will have a look to include the js file when I have the chance! I think the flag may not be needed, it's pretty cool to have rdf highlights by default

dgarijo avatar May 15 '24 13:05 dgarijo