Question

I am writing this post to ask about the best way you think it should be done. I have a task to implement new brush for Gorbachev SyntaxHighlighter. But I don't know sparql at all. After searching I got the idea to port one of the ready highlighter. I choose one python based. But it is lexer. https://github.com/gniezen/n3pygments/tree/master/swlexers Looking for opinion on the approach and eventually if you can prompt me a better solution. Any feedback is welcome.

Best regards.

Was it helpful?

Solution

I will say you have to do the same as syntax highlighter does for other language, SPARQL is nothing but a Query Language, with its keywords from W3.org we can identify the keywords that is required to highlight,

For Example Simple Query:

SELECT ?title
WHERE
{
  <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title .
}

Here we need to highlight SELECT ?title that is twice there and where with opening and closing braces { with } , so that should do in this case,

so create list on bases of language keywords and that will help you finish the task :)

I hope this will help..

OTHER TIPS

The best way would be to read the language specification. But if you are too lazy for that, you may take a look to other highlighters, such as codemirror: https://github.com/marijnh/CodeMirror/blob/master/mode/sparql/sparql.js

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top