-
Notifications
You must be signed in to change notification settings - Fork 8
Syntax highlighting Turtle, ShEx, SPARQL, etc in docs
Jose Emilio Labra Gayo edited this page Oct 18, 2024
·
1 revision
After some search, we found a way to highlight the syntax of source code snippets in custom languages which are not currently supported by default in mdbook.
The trick is more or less explained in this issue although we followed a different approach.
We didn't have to use a custom highlight.js and remained with the one that comes by default.
We added our three custom syntax highlight functions which were borrowed from the following repos:
We adapted those files to register only the toplevel function and added our own version to the docs folder.
We created a single line file init_highlight_on_load.js which contains this line:
hljs.initHighlightingOnLoad();
And we added all those files in the book.toml section:
additional-js = [
"turtle.js",
"shexc.js",
"sparql.js",
"init_highlight_on_load.js", # This is required as the last one after the custom highlight files to restart highlight
...
And it seems to work.
- (RDF) Information about a node in RDF file
- (RDF) Merge several RDF data files
- (RDF/SPARQL) Information about a node in Wikidata
- (ShEx) Show info about a schema
- (ShEx) Validate a specific node with a shape
- (SHACL) Show info about a SHACL schema
- (SHACL) Read a SHACL Shapes graph and convert to some format
- (SHACL) Validating RDF data using SHACL
- (SPARQL) Running SPARQL queries
- (Python) Invoking this library from Python
- (SHACL → ShEx) Convert SHACL shapes graph to ShEx schema
- (ShEx → SVG/PNG/...) Convert a ShEx schema to an UML-like visualization in SVG, PNG, ...
- (ShEx → HTML) Convert ShEx schemas to HTML views
- (ShEx → SPARQL) Convert a simple ShEx schema to SPARQL
- (DCTap → ShEx) Convert a CSV file in DCTap to a ShEx schema
- (DCTap → SVG/PNG/...) Convert a CSV file in DCTap to an UML-like visualization in SVG, PNG, ...