update to higlight.js 8.4
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
Language: Clojure
|
||||
Description: Clojure syntax (based on lisp.js)
|
||||
Author: mfornos
|
||||
Category: lisp
|
||||
*/
|
||||
|
||||
function(hljs) {
|
||||
var keywords = {
|
||||
built_in:
|
||||
// Clojure keywords
|
||||
'def cond apply if-not if-let if not not= = < < > <= <= >= == + / * - rem '+
|
||||
'def cond apply if-not if-let if not not= = < > <= >= == + / * - rem '+
|
||||
'quot neg? pos? delay? symbol? keyword? true? false? integer? empty? coll? list? '+
|
||||
'set? ifn? fn? associative? sequential? sorted? counted? reversible? number? decimal? '+
|
||||
'class? distinct? isa? float? rational? reduced? ratio? odd? even? char? seq? vector? '+
|
||||
@@ -37,9 +38,14 @@ function(hljs) {
|
||||
'lazy-seq spread list* str find-keyword keyword symbol gensym force rationalize'
|
||||
};
|
||||
|
||||
var CLJ_IDENT_RE = '[a-zA-Z_0-9\\!\\.\\?\\-\\+\\*\\/\\<\\=\\>\\&\\#\\$\';]+';
|
||||
var SIMPLE_NUMBER_RE = '[\\s:\\(\\{]+\\d+(\\.\\d+)?';
|
||||
var SYMBOLSTART = 'a-zA-Z_\\-!.?+*=<>&#\'';
|
||||
var SYMBOL_RE = '[' + SYMBOLSTART + '][' + SYMBOLSTART + '0-9/;:]*';
|
||||
var SIMPLE_NUMBER_RE = '[-+]?\\d+(\\.\\d+)?';
|
||||
|
||||
var SYMBOL = {
|
||||
begin: SYMBOL_RE,
|
||||
relevance: 0
|
||||
};
|
||||
var NUMBER = {
|
||||
className: 'number', begin: SIMPLE_NUMBER_RE,
|
||||
relevance: 0
|
||||
@@ -50,13 +56,17 @@ function(hljs) {
|
||||
begin: ';', end: '$',
|
||||
relevance: 0
|
||||
};
|
||||
var LITERAL = {
|
||||
className: 'literal',
|
||||
begin: /\b(true|false|nil)\b/
|
||||
}
|
||||
var COLLECTION = {
|
||||
className: 'collection',
|
||||
begin: '[\\[\\{]', end: '[\\]\\}]'
|
||||
};
|
||||
var HINT = {
|
||||
className: 'comment',
|
||||
begin: '\\^' + CLJ_IDENT_RE
|
||||
begin: '\\^' + SYMBOL_RE
|
||||
};
|
||||
var HINT_COL = {
|
||||
className: 'comment',
|
||||
@@ -65,7 +75,7 @@ function(hljs) {
|
||||
};
|
||||
var KEY = {
|
||||
className: 'attribute',
|
||||
begin: '[:]' + CLJ_IDENT_RE
|
||||
begin: '[:]' + SYMBOL_RE
|
||||
};
|
||||
var LIST = {
|
||||
className: 'list',
|
||||
@@ -73,31 +83,23 @@ function(hljs) {
|
||||
};
|
||||
var BODY = {
|
||||
endsWithParent: true,
|
||||
keywords: {literal: 'true false nil'},
|
||||
relevance: 0
|
||||
};
|
||||
var TITLE = {
|
||||
var NAME = {
|
||||
keywords: keywords,
|
||||
lexemes: CLJ_IDENT_RE,
|
||||
className: 'title', begin: CLJ_IDENT_RE,
|
||||
lexemes: SYMBOL_RE,
|
||||
className: 'keyword', begin: SYMBOL_RE,
|
||||
starts: BODY
|
||||
};
|
||||
var DEFAULT_CONTAINS = [LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL, SYMBOL];
|
||||
|
||||
LIST.contains = [{className: 'comment', begin: 'comment'}, TITLE, BODY];
|
||||
BODY.contains = [LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER];
|
||||
COLLECTION.contains = [LIST, STRING, HINT, COMMENT, KEY, COLLECTION, NUMBER];
|
||||
LIST.contains = [{className: 'comment', begin: 'comment'}, NAME, BODY];
|
||||
BODY.contains = DEFAULT_CONTAINS;
|
||||
COLLECTION.contains = DEFAULT_CONTAINS;
|
||||
|
||||
return {
|
||||
aliases: ['clj'],
|
||||
illegal: /\S/,
|
||||
contains: [
|
||||
COMMENT,
|
||||
LIST,
|
||||
{
|
||||
className: 'prompt',
|
||||
begin: /^=> /,
|
||||
starts: {end: /\n\n|\Z/} // eat up prompt output to not interfere with the illegal
|
||||
}
|
||||
]
|
||||
contains: [LIST, STRING, HINT, HINT_COL, COMMENT, KEY, COLLECTION, NUMBER, LITERAL]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user