dgarijo / Widoco

Wizard for documenting ontologies. WIDOCO is a step by step generator of HTML templates with the documentation of your ontology. It uses the LODE environment to create part of the template.
Apache License 2.0
295 stars 89 forks source link

Codeblock highlight for SPARQL and turtle #704

Open vemonet opened 6 months ago

vemonet commented 6 months ago

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

dgarijo commented 6 months ago

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