Skip to content

Instantly share code, notes, and snippets.

@vsimko
Last active April 23, 2024 10:05
Show Gist options
  • Save vsimko/fcc84e1e4f8e750746caa34b802db5a7 to your computer and use it in GitHub Desktop.
Save vsimko/fcc84e1e4f8e750746caa34b802db5a7 to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage[dvipsnames]{xcolor} % https://en.wikibooks.org/wiki/LaTeX/Colors
\definecolor{LightGray}{rgb}{0.97,0.97,0.97}
\usepackage{listings} % syntax highlighting
\lstdefinelanguage{SPARQL}{
basicstyle=\small\ttfamily,
backgroundcolor=\color{LightGray},
columns=fullflexible,
breaklines=false,
sensitive=true,
% --------------------------
frame=bt,
aboveskip=1em,
belowskip=1em,
xleftmargin=.5em,
xrightmargin=.5em,
framexleftmargin=.5em,
framextopmargin=.5em,
framexbottommargin=.5em,
framexrightmargin=.5em,
% --------------------------
tabsize = 2,
showstringspaces=false,
morecomment=[l][\color{gray}]{\#}, % comments
morecomment=[n][\color{blue}]{<http}{>}, % uris
morestring=[b][\color{OliveGreen}]{\"}, % strings
% -------------------------- variables
keywordsprefix=?,
classoffset=0,
keywordstyle=\color{Sepia},
morekeywords={},
% -------------------------- prefixes
classoffset=1,
keywordstyle=\color{Purple},
morekeywords={rdf,rdfs,owl,xsd,purl},
% -------------------------- keywords
classoffset=2,
keywordstyle=\color{MidnightBlue},
morekeywords={
SELECT,CONSTRUCT,DESCRIBE,ASK,WHERE,FROM,NAMED,PREFIX,BASE,OPTIONAL,
FILTER,GRAPH,LIMIT,OFFSET,SERVICE,UNION,EXISTS,NOT,BINDINGS,MINUS,a
}
}
\begin{document}
\begin{lstlisting}[language=SPARQL]
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# this is a comment
SELECT ?url ?name
WHERE {
?url rdf:type java:Package .
?url rdfs:label ?name .
FILTER( match(?name, "hello" ))
}
\end{lstlisting}
\end{document}
@vsimko
Copy link
Author

vsimko commented Mar 22, 2024

glad to hear that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment