-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
153 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/* | ||
Language: Turtle | ||
Author: Redmer KRONEMEIJER <redmer.kronemeijer@rdmr.eu> | ||
Contributors: Mark ELLIS <mark.ellis@stardog.com>, Vladimir ALEXIEV <vladimir.alexiev@ontotext.com> | ||
*/ | ||
function hljsDefineTurtle(hljs) { | ||
var KEYWORDS = { | ||
keyword: "BASE|2 PREFIX|5 @base|10 @prefix|10", | ||
literal: "true false", | ||
built_in: "a", | ||
}; | ||
|
||
var IRI_LITERAL = { | ||
className: "literal", | ||
relevance: 1, | ||
begin: /</, | ||
end: />/, | ||
}; | ||
|
||
var PN_CHARS_BASE = | ||
"A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u10000-\uEFFFF"; | ||
var PN_CHARS_U = PN_CHARS_BASE + "_"; | ||
var PN_CHARS = "-" + PN_CHARS_U + "0-9\u00B7\u0300-\u036F\u203F-\u2040"; | ||
var BLANK_NODE_LABEL = | ||
"_:" + PN_CHARS_U + "0-9?"; | ||
var PN_PREFIX = | ||
"" + PN_CHARS_BASE + "?"; | ||
var PERCENT = "%[0-9A-Fa-f][0-9A-Fa-f]"; | ||
var PN_LOCAL_ESC = "\\\\[_~.!$&'()*+,;=/?#@%-]"; | ||
var PLX = PERCENT + "|" + PN_LOCAL_ESC; | ||
var PNAME_NS = "(" + PN_PREFIX + ")?:"; | ||
var PN_LOCAL = | ||
"([" + | ||
PN_CHARS_U + | ||
":0-9]|" + | ||
PLX + | ||
")([" + | ||
PN_CHARS + | ||
".:]|" + | ||
PLX + | ||
")*([" + | ||
PN_CHARS + | ||
":]|" + | ||
PLX + | ||
")?"; | ||
var PNAME_LN = PNAME_NS + PN_LOCAL; | ||
var PNAME_NS_or_LN = PNAME_NS + "(" + PN_LOCAL + ")?"; | ||
|
||
var PNAME = { | ||
begin: PNAME_NS_or_LN, | ||
relevance: 0, | ||
className: "symbol", | ||
}; | ||
|
||
var BLANK_NODE = { | ||
begin: BLANK_NODE_LABEL, | ||
relevance: 10, | ||
className: "template-variable", | ||
}; | ||
|
||
var LANGTAG = { | ||
begin: /@[a-zA-Z]+([a-zA-Z0-9-]+)*/, | ||
className: "type", | ||
relevance: 0, | ||
}; | ||
|
||
var DATATYPE = { | ||
begin: "\\^\\^" + PNAME_LN, | ||
className: "type", | ||
relevance: 10, | ||
}; | ||
|
||
var TRIPLE_APOS_STRING = { | ||
begin: /'''/, | ||
end: /'''/, | ||
className: "string", | ||
relevance: 0, | ||
}; | ||
|
||
var TRIPLE_QUOTE_STRING = { | ||
begin: /"""/, | ||
end: /"""/, | ||
className: "string", | ||
relevance: 0, | ||
}; | ||
|
||
var APOS_STRING_LITERAL = JSON.parse(JSON.stringify(hljs.APOS_STRING_MODE)); | ||
APOS_STRING_LITERAL.relevance = 0; | ||
|
||
var QUOTE_STRING_LITERAL = JSON.parse(JSON.stringify(hljs.QUOTE_STRING_MODE)); | ||
QUOTE_STRING_LITERAL.relevance = 0; | ||
|
||
return { | ||
name: "Turtle", | ||
case_insensitive: true, | ||
keywords: KEYWORDS, | ||
aliases: ["turtle", "ttl", "n3"], | ||
contains: [ | ||
LANGTAG, | ||
DATATYPE, | ||
IRI_LITERAL, | ||
BLANK_NODE, | ||
PNAME, | ||
TRIPLE_APOS_STRING, | ||
TRIPLE_QUOTE_STRING, | ||
APOS_STRING_LITERAL, | ||
QUOTE_STRING_LITERAL, | ||
hljs.C_NUMBER_MODE, | ||
hljs.HASH_COMMENT_MODE, | ||
], | ||
}; | ||
} | ||
|
||
module.exports = hljsDefineTurtle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters