highlight.js
Advanced tools
Comparing version 7.2.0 to 7.3.0
module.exports = function(hljs) { | ||
var BASH_LITERAL = 'true false'; | ||
var BASH_KEYWORD = 'if then else elif fi for break continue while in do done echo exit return set declare'; | ||
var VAR1 = { | ||
className: 'variable', begin: '\\$[a-zA-Z0-9_]+\\b' | ||
className: 'variable', begin: '\\$[a-zA-Z0-9_#]+' | ||
}; | ||
@@ -34,3 +35,3 @@ var VAR2 = { | ||
keywords: { | ||
keyword: 'if then else fi for break continue while in do done echo exit return set declare', | ||
keyword: BASH_KEYWORD, | ||
literal: BASH_LITERAL | ||
@@ -37,0 +38,0 @@ }, |
@@ -90,3 +90,2 @@ module.exports = function(hljs) { | ||
return { | ||
case_insensitive: true, | ||
illegal: '\\S', | ||
@@ -93,0 +92,0 @@ contains: [ |
module.exports = function(hljs) { | ||
var keywords = { | ||
var KEYWORDS = { | ||
keyword: | ||
// JS keywords | ||
'in if for while finally new do return else break catch instanceof throw try this ' + | ||
'switch continue typeof delete debugger class extends super' + | ||
'switch continue typeof delete debugger super ' + | ||
// Coffee keywords | ||
@@ -17,88 +17,86 @@ 'then unless until loop of by when and or is isnt not', | ||
}; | ||
var JS_IDENT_RE = '[A-Za-z$_][0-9A-Za-z$_]*'; | ||
var COFFEE_QUOTE_STRING_SUBST_MODE = { | ||
var TITLE = {className: 'title', begin: JS_IDENT_RE}; | ||
var SUBST = { | ||
className: 'subst', | ||
begin: '#\\{', end: '}', | ||
keywords: keywords, | ||
contains: [hljs.C_NUMBER_MODE, hljs.BINARY_NUMBER_MODE] | ||
keywords: KEYWORDS, | ||
contains: [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE] | ||
}; | ||
var COFFEE_QUOTE_STRING_MODE = { | ||
className: 'string', | ||
begin: '"', end: '"', | ||
relevance: 0, | ||
contains: [hljs.BACKSLASH_ESCAPE, COFFEE_QUOTE_STRING_SUBST_MODE] | ||
}; | ||
var COFFEE_HEREDOC_MODE = { | ||
className: 'string', | ||
begin: '"""', end: '"""', | ||
contains: [hljs.BACKSLASH_ESCAPE, COFFEE_QUOTE_STRING_SUBST_MODE] | ||
}; | ||
var COFFEE_HERECOMMENT_MODE = { | ||
className: 'comment', | ||
begin: '###', end: '###' | ||
}; | ||
var COFFEE_HEREGEX_MODE = { | ||
className: 'regexp', | ||
begin: '///', end: '///', | ||
contains: [hljs.HASH_COMMENT_MODE] | ||
}; | ||
var COFFEE_EMPTY_REGEX_MODE = { | ||
className: 'regexp', begin: '//[gim]*' | ||
}; | ||
var COFFEE_REGEX_MODE = { | ||
className: 'regexp', | ||
begin: '/\\S(\\\\.|[^\\n])*/[gim]*' // \S is required to parse x / 2 / 3 as two divisions | ||
}; | ||
var COFFEE_FUNCTION_DECLARATION_MODE = { | ||
className: 'function', | ||
begin: JS_IDENT_RE + '\\s*=\\s*(\\(.+\\))?\\s*[-=]>', | ||
returnBegin: true, | ||
contains: [ | ||
{ | ||
className: 'title', | ||
begin: JS_IDENT_RE | ||
}, | ||
{ | ||
className: 'params', | ||
begin: '\\(', end: '\\)' | ||
} | ||
] | ||
}; | ||
var COFFEE_EMBEDDED_JAVASCRIPT = { | ||
begin: '`', end: '`', | ||
excludeBegin: true, excludeEnd: true, | ||
subLanguage: 'javascript' | ||
}; | ||
return { | ||
keywords: keywords, | ||
keywords: KEYWORDS, | ||
contains: [ | ||
// Numbers | ||
hljs.BINARY_NUMBER_MODE, | ||
hljs.C_NUMBER_MODE, | ||
hljs.BINARY_NUMBER_MODE, | ||
// Strings | ||
hljs.APOS_STRING_MODE, | ||
COFFEE_HEREDOC_MODE, // Should be before COFFEE_QUOTE_STRING_MODE for greater priority | ||
COFFEE_QUOTE_STRING_MODE, | ||
{ | ||
className: 'string', | ||
begin: '"""', end: '"""', | ||
contains: [hljs.BACKSLASH_ESCAPE, SUBST] | ||
}, | ||
{ | ||
className: 'string', | ||
begin: '"', end: '"', | ||
contains: [hljs.BACKSLASH_ESCAPE, SUBST], | ||
relevance: 0 | ||
}, | ||
// Comments | ||
COFFEE_HERECOMMENT_MODE, // Should be before hljs.HASH_COMMENT_MODE for greater priority | ||
{ | ||
className: 'comment', | ||
begin: '###', end: '###' | ||
}, | ||
hljs.HASH_COMMENT_MODE, | ||
// CoffeeScript specific modes | ||
COFFEE_HEREGEX_MODE, | ||
COFFEE_EMPTY_REGEX_MODE, | ||
COFFEE_REGEX_MODE, | ||
COFFEE_EMBEDDED_JAVASCRIPT, | ||
COFFEE_FUNCTION_DECLARATION_MODE | ||
{ | ||
className: 'regexp', | ||
begin: '///', end: '///', | ||
contains: [hljs.HASH_COMMENT_MODE] | ||
}, | ||
{ | ||
className: 'regexp', begin: '//[gim]*' | ||
}, | ||
{ | ||
className: 'regexp', | ||
begin: '/\\S(\\\\.|[^\\n])*/[gim]*' // \S is required to parse x / 2 / 3 as two divisions | ||
}, | ||
{ | ||
begin: '`', end: '`', | ||
excludeBegin: true, excludeEnd: true, | ||
subLanguage: 'javascript' | ||
}, | ||
{ | ||
className: 'function', | ||
begin: JS_IDENT_RE + '\\s*=\\s*(\\(.+\\))?\\s*[-=]>', | ||
returnBegin: true, | ||
contains: [ | ||
TITLE, | ||
{ | ||
className: 'params', | ||
begin: '\\(', end: '\\)' | ||
} | ||
] | ||
}, | ||
{ | ||
className: 'class', | ||
beginWithKeyword: true, keywords: 'class', | ||
end: '$', | ||
illegal: ':', | ||
contains: [ | ||
{ | ||
beginWithKeyword: true, keywords: 'extends', | ||
endsWithParent: true, | ||
illegal: ':', | ||
contains: [TITLE] | ||
}, | ||
TITLE | ||
] | ||
}, | ||
{ | ||
className: 'property', | ||
begin: '@' + JS_IDENT_RE | ||
} | ||
] | ||
}; | ||
}; |
module.exports = function(hljs) { | ||
return { | ||
case_insensitive: true, | ||
contains: [ | ||
@@ -5,0 +4,0 @@ { |
@@ -12,3 +12,3 @@ module.exports = function(hljs) { | ||
{ | ||
className: 'input_number', begin: '^[0-9]+> ', | ||
className: 'prompt', begin: '^[0-9]+> ', | ||
relevance: 10 | ||
@@ -15,0 +15,0 @@ }, |
265
highlight.js
@@ -6,8 +6,7 @@ var hljs = new function() { | ||
function escape(value) { | ||
return value.replace(/&/gm, '&').replace(/</gm, '<'); | ||
return value.replace(/&/gm, '&').replace(/</gm, '<').replace(/>/gm, '>'); | ||
} | ||
function findCode(pre) { | ||
for (var i = 0; i < pre.childNodes.length; i++) { | ||
var node = pre.childNodes[i]; | ||
for (var node = pre.firstChild; node; node = node.nextSibling) { | ||
if (node.nodeName == 'CODE') | ||
@@ -20,28 +19,20 @@ return node; | ||
var is_old_IE = (typeof navigator !== 'undefined' && /MSIE [678]/.test(navigator.userAgent)); | ||
function blockText(block, ignoreNewLines) { | ||
var result = ''; | ||
for (var i = 0; i < block.childNodes.length; i++) | ||
if (block.childNodes[i].nodeType == 3) { | ||
var chunk = block.childNodes[i].nodeValue; | ||
if (ignoreNewLines) | ||
chunk = chunk.replace(/\n/g, ''); | ||
result += chunk; | ||
} else if (block.childNodes[i].nodeName == 'BR') | ||
result += '\n'; | ||
else | ||
result += blockText(block.childNodes[i]); | ||
if (is_old_IE) | ||
result = result.replace(/\r/g, '\n'); | ||
return result; | ||
return Array.prototype.map.call(block.childNodes, function(node) { | ||
if (node.nodeType == 3) { | ||
return ignoreNewLines ? node.nodeValue.replace(/\n/g, '') : node.nodeValue; | ||
} | ||
if (node.nodeName == 'BR') { | ||
return '\n'; | ||
} | ||
return blockText(node, ignoreNewLines); | ||
}).join(''); | ||
} | ||
function blockLanguage(block) { | ||
var classes = block.className.split(/\s+/); | ||
classes = classes.concat(block.parentNode.className.split(/\s+/)); | ||
var classes = (block.className + ' ' + block.parentNode.className).split(/\s+/); | ||
classes = classes.map(function(c) {return c.replace(/^language-/, '')}); | ||
for (var i = 0; i < classes.length; i++) { | ||
var class_ = classes[i].replace(/^language-/, ''); | ||
if (languages[class_] || class_ == 'no-highlight') { | ||
return class_; | ||
if (languages[classes[i]] || classes[i] == 'no-highlight') { | ||
return classes[i]; | ||
} | ||
@@ -56,18 +47,18 @@ } | ||
(function _nodeStream(node, offset) { | ||
for (var i = 0; i < node.childNodes.length; i++) { | ||
if (node.childNodes[i].nodeType == 3) | ||
offset += node.childNodes[i].nodeValue.length; | ||
else if (node.childNodes[i].nodeName == 'BR') | ||
for (var child = node.firstChild; child; child = child.nextSibling) { | ||
if (child.nodeType == 3) | ||
offset += child.nodeValue.length; | ||
else if (child.nodeName == 'BR') | ||
offset += 1; | ||
else if (node.childNodes[i].nodeType == 1) { | ||
else if (child.nodeType == 1) { | ||
result.push({ | ||
event: 'start', | ||
offset: offset, | ||
node: node.childNodes[i] | ||
node: child | ||
}); | ||
offset = _nodeStream(node.childNodes[i], offset); | ||
offset = _nodeStream(child, offset); | ||
result.push({ | ||
event: 'stop', | ||
offset: offset, | ||
node: node.childNodes[i] | ||
node: child | ||
}); | ||
@@ -114,11 +105,4 @@ } | ||
function open(node) { | ||
var result = '<' + node.nodeName.toLowerCase(); | ||
for (var i = 0; i < node.attributes.length; i++) { | ||
var attribute = node.attributes[i]; | ||
result += ' ' + attribute.nodeName.toLowerCase(); | ||
if (attribute.value !== undefined && attribute.value !== false && attribute.value !== null) { | ||
result += '="' + escape(attribute.value) + '"'; | ||
} | ||
} | ||
return result + '>'; | ||
function attr_str(a) {return ' ' + a.nodeName + '="' + escape(a.value) + '"'}; | ||
return '<' + node.nodeName + Array.prototype.map.call(node.attributes, attr_str).join('') + '>'; | ||
} | ||
@@ -171,8 +155,7 @@ | ||
function flatten(className, str) { | ||
var group = str.split(' '); | ||
for (var i = 0; i < group.length; i++) { | ||
var pair = group[i].split('|'); | ||
str.split(' ').forEach(function(kw) { | ||
var pair = kw.split('|'); | ||
compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1]; | ||
keywords.push(pair[0]); | ||
} | ||
}); | ||
} | ||
@@ -232,3 +215,3 @@ | ||
} | ||
mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : null; | ||
mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : {exec: function(s) {return null;}}; | ||
} | ||
@@ -259,10 +242,9 @@ | ||
function endOfMode(mode_index, lexem) { | ||
if (modes[mode_index].end && modes[mode_index].endRe.test(lexem)) | ||
return 1; | ||
if (modes[mode_index].endsWithParent) { | ||
var level = endOfMode(mode_index - 1, lexem); | ||
return level ? level + 1 : 0; | ||
function endOfMode(mode, lexem) { | ||
if (mode.end && mode.endRe.test(lexem)) { | ||
return mode; | ||
} | ||
return 0; | ||
if (mode.endsWithParent) { | ||
return endOfMode(mode.parent, lexem); | ||
} | ||
} | ||
@@ -274,29 +256,18 @@ | ||
function eatModeChunk(value, index) { | ||
var mode = modes[modes.length - 1]; | ||
if (mode.terminators) { | ||
mode.terminators.lastIndex = index; | ||
return mode.terminators.exec(value); | ||
} | ||
} | ||
function keywordMatch(mode, match) { | ||
var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0]; | ||
var value = mode.keywords[match_str]; | ||
if (value && value instanceof Array) | ||
return value; | ||
return false; | ||
return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str]; | ||
} | ||
function processKeywords(buffer, mode) { | ||
buffer = escape(buffer); | ||
if (!mode.keywords) | ||
function processKeywords() { | ||
var buffer = escape(mode_buffer); | ||
if (!top.keywords) | ||
return buffer; | ||
var result = ''; | ||
var last_index = 0; | ||
mode.lexemsRe.lastIndex = 0; | ||
var match = mode.lexemsRe.exec(buffer); | ||
top.lexemsRe.lastIndex = 0; | ||
var match = top.lexemsRe.exec(buffer); | ||
while (match) { | ||
result += buffer.substr(last_index, match.index - last_index); | ||
var keyword_match = keywordMatch(mode, match); | ||
var keyword_match = keywordMatch(top, match); | ||
if (keyword_match) { | ||
@@ -308,4 +279,4 @@ keyword_count += keyword_match[1]; | ||
} | ||
last_index = mode.lexemsRe.lastIndex; | ||
match = mode.lexemsRe.exec(buffer); | ||
last_index = top.lexemsRe.lastIndex; | ||
match = top.lexemsRe.exec(buffer); | ||
} | ||
@@ -315,9 +286,7 @@ return result + buffer.substr(last_index); | ||
function processSubLanguage(buffer, mode) { | ||
var result; | ||
if (mode.subLanguage == '') { | ||
result = highlightAuto(buffer); | ||
} else { | ||
result = highlight(mode.subLanguage, buffer); | ||
function processSubLanguage() { | ||
if (top.subLanguage && !languages[top.subLanguage]) { | ||
return escape(mode_buffer); | ||
} | ||
var result = top.subLanguage ? highlight(top.subLanguage, mode_buffer) : highlightAuto(mode_buffer); | ||
// Counting embedded language score towards the host language may be disabled | ||
@@ -327,3 +296,3 @@ // with zeroing the containing mode relevance. Usecase in point is Markdown that | ||
// score. | ||
if (mode.relevance > 0) { | ||
if (top.relevance > 0) { | ||
keyword_count += result.keyword_count; | ||
@@ -335,8 +304,4 @@ relevance += result.relevance; | ||
function processBuffer(buffer, mode) { | ||
if (mode.subLanguage && languages[mode.subLanguage] || mode.subLanguage == '') { | ||
return processSubLanguage(buffer, mode); | ||
} else { | ||
return processKeywords(buffer, mode); | ||
} | ||
function processBuffer() { | ||
return top.subLanguage !== undefined ? processSubLanguage() : processKeywords(); | ||
} | ||
@@ -348,55 +313,60 @@ | ||
result += markup; | ||
mode.buffer = ''; | ||
mode_buffer = ''; | ||
} else if (mode.excludeBegin) { | ||
result += escape(lexem) + markup; | ||
mode.buffer = ''; | ||
mode_buffer = ''; | ||
} else { | ||
result += markup; | ||
mode.buffer = lexem; | ||
mode_buffer = lexem; | ||
} | ||
modes.push(mode); | ||
top = Object.create(mode, {parent: {value: top}}); | ||
relevance += mode.relevance; | ||
} | ||
function processModeInfo(buffer, lexem) { | ||
var current_mode = modes[modes.length - 1]; | ||
function processLexem(buffer, lexem) { | ||
mode_buffer += buffer; | ||
if (lexem === undefined) { | ||
result += processBuffer(current_mode.buffer + buffer, current_mode); | ||
return; | ||
result += processBuffer(); | ||
return 0; | ||
} | ||
var new_mode = subMode(lexem, current_mode); | ||
var new_mode = subMode(lexem, top); | ||
if (new_mode) { | ||
result += processBuffer(current_mode.buffer + buffer, current_mode); | ||
result += processBuffer(); | ||
startNewMode(new_mode, lexem); | ||
return new_mode.returnBegin; | ||
return new_mode.returnBegin ? 0 : lexem.length; | ||
} | ||
var end_level = endOfMode(modes.length - 1, lexem); | ||
if (end_level) { | ||
var markup = current_mode.className?'</span>':''; | ||
if (current_mode.returnEnd) { | ||
result += processBuffer(current_mode.buffer + buffer, current_mode) + markup; | ||
} else if (current_mode.excludeEnd) { | ||
result += processBuffer(current_mode.buffer + buffer, current_mode) + markup + escape(lexem); | ||
} else { | ||
result += processBuffer(current_mode.buffer + buffer + lexem, current_mode) + markup; | ||
var end_mode = endOfMode(top, lexem); | ||
if (end_mode) { | ||
if (!(end_mode.returnEnd || end_mode.excludeEnd)) { | ||
mode_buffer += lexem; | ||
} | ||
while (end_level > 1) { | ||
markup = modes[modes.length - 2].className?'</span>':''; | ||
result += markup; | ||
end_level--; | ||
modes.length--; | ||
result += processBuffer(); | ||
do { | ||
if (top.className) { | ||
result += '</span>'; | ||
} | ||
top = top.parent; | ||
} while (top != end_mode.parent); | ||
if (end_mode.excludeEnd) { | ||
result += escape(lexem); | ||
} | ||
var last_ended_mode = modes[modes.length - 1]; | ||
modes.length--; | ||
modes[modes.length - 1].buffer = ''; | ||
if (last_ended_mode.starts) { | ||
startNewMode(last_ended_mode.starts, ''); | ||
mode_buffer = ''; | ||
if (end_mode.starts) { | ||
startNewMode(end_mode.starts, ''); | ||
} | ||
return current_mode.returnEnd; | ||
return end_mode.returnEnd ? 0 : lexem.length; | ||
} | ||
if (isIllegal(lexem, current_mode)) | ||
if (isIllegal(lexem, top)) | ||
throw 'Illegal'; | ||
/* | ||
Parser should not reach this point as all types of lexems should be caught | ||
earlier, but if it does due to some bug make sure it advances at least one | ||
character forward to prevent infinite looping. | ||
*/ | ||
mode_buffer += lexem; | ||
return lexem.length || 1; | ||
} | ||
@@ -406,4 +376,4 @@ | ||
compileLanguage(language); | ||
var modes = [language]; | ||
language.buffer = ''; | ||
var top = language; | ||
var mode_buffer = ''; | ||
var relevance = 0; | ||
@@ -413,11 +383,12 @@ var keyword_count = 0; | ||
try { | ||
var match, index = 0; | ||
var match, count, index = 0; | ||
while (true) { | ||
match = eatModeChunk(value, index); | ||
top.terminators.lastIndex = index; | ||
match = top.terminators.exec(value); | ||
if (!match) | ||
break; | ||
var return_lexem = processModeInfo(value.substr(index, match.index - index), match[0]); | ||
index = match.index + (return_lexem ? 0 : match[0].length); | ||
count = processLexem(value.substr(index, match.index - index), match[0]); | ||
index = match.index + count; | ||
} | ||
processModeInfo(value.substr(index), undefined); | ||
processLexem(value.substr(index)) | ||
return { | ||
@@ -506,14 +477,9 @@ relevance: relevance, | ||
var language = blockLanguage(block); | ||
var result, pre; | ||
if (language == 'no-highlight') | ||
return; | ||
if (language) { | ||
result = highlight(language, text); | ||
} else { | ||
result = highlightAuto(text); | ||
language = result.language; | ||
} | ||
var result = language ? highlight(language, text) : highlightAuto(text); | ||
language = result.language; | ||
var original = nodeStream(block); | ||
if (original.length) { | ||
pre = document.createElement('pre'); | ||
var pre = document.createElement('pre'); | ||
pre.innerHTML = result.value; | ||
@@ -528,14 +494,3 @@ result.value = mergeStreams(original, nodeStream(pre), text); | ||
} | ||
if (is_old_IE && block.tagName == 'CODE' && block.parentNode.tagName == 'PRE') { | ||
// This is for backwards compatibility only. IE needs this strange | ||
// hack becasue it cannot just cleanly replace <code> block contents. | ||
pre = block.parentNode; | ||
var container = document.createElement('div'); | ||
container.innerHTML = '<pre><code>' + result.value + '</code></pre>'; | ||
block = container.firstChild.firstChild; | ||
container.firstChild.className = pre.className; | ||
pre.parentNode.replaceChild(container.firstChild, pre); | ||
} else { | ||
block.innerHTML = result.value; | ||
} | ||
block.innerHTML = result.value; | ||
block.className = class_name; | ||
@@ -563,8 +518,5 @@ block.result = { | ||
initHighlighting.called = true; | ||
var pres = document.getElementsByTagName('pre'); | ||
for (var i = 0; i < pres.length; i++) { | ||
var code = findCode(pres[i]); | ||
if (code) | ||
highlightBlock(code, hljs.tabReplace); | ||
} | ||
Array.prototype.map.call(document.getElementsByTagName('pre'), findCode). | ||
filter(Boolean). | ||
forEach(function(code){highlightBlock(code, hljs.tabReplace)}); | ||
} | ||
@@ -576,9 +528,4 @@ | ||
function initHighlightingOnLoad() { | ||
if (window.addEventListener) { | ||
window.addEventListener('DOMContentLoaded', initHighlighting, false); | ||
window.addEventListener('load', initHighlighting, false); | ||
} else if (window.attachEvent) | ||
window.attachEvent('onload', initHighlighting); | ||
else | ||
window.onload = initHighlighting; | ||
window.addEventListener('DOMContentLoaded', initHighlighting, false); | ||
window.addEventListener('load', initHighlighting, false); | ||
} | ||
@@ -666,2 +613,3 @@ | ||
hljs.LANGUAGES['cs'] = require('./cs.js')(hljs); | ||
hljs.LANGUAGES['brainfuck'] = require('./brainfuck.js')(hljs); | ||
hljs.LANGUAGES['ruby'] = require('./ruby.js')(hljs); | ||
@@ -711,2 +659,3 @@ hljs.LANGUAGES['rust'] = require('./rust.js')(hljs); | ||
hljs.LANGUAGES['apache'] = require('./apache.js')(hljs); | ||
hljs.LANGUAGES['applescript'] = require('./applescript.js')(hljs); | ||
hljs.LANGUAGES['cpp'] = require('./cpp.js')(hljs); | ||
@@ -713,0 +662,0 @@ hljs.LANGUAGES['matlab'] = require('./matlab.js')(hljs); |
@@ -17,3 +17,3 @@ module.exports = function(hljs) { | ||
hljs.C_NUMBER_MODE, | ||
{ // regexp container | ||
{ // "value" container | ||
begin: '(' + hljs.RE_STARTERS_RE + '|\\b(case|return|throw)\\b)\\s*', | ||
@@ -27,3 +27,8 @@ keywords: 'return throw case', | ||
begin: '/', end: '/[gim]*', | ||
illegal: '\\n', | ||
contains: [{begin: '\\\\/'}] | ||
}, | ||
{ // E4X | ||
begin: '<', end: '>;', | ||
subLanguage: 'xml' | ||
} | ||
@@ -30,0 +35,0 @@ ], |
@@ -70,3 +70,2 @@ module.exports = function(hljs) { | ||
return { | ||
case_insensitive: true, | ||
illegal: '[^\\s]', | ||
@@ -73,0 +72,0 @@ contains: NUMBERS.concat([ |
module.exports = function(hljs) { | ||
return { | ||
case_insensitive: true, | ||
contains: [ | ||
@@ -5,0 +4,0 @@ // highlight headers |
@@ -234,2 +234,14 @@ { | ||
"email": "gimenete@gmail.com" | ||
}, | ||
{ | ||
"name": "Kirk Kimmel", | ||
"email": "kimmel.k.programmer@gmail.com" | ||
}, | ||
{ | ||
"name": "Nathan Grigg", | ||
"email": "nathan@nathanamy.org" | ||
}, | ||
{ | ||
"name": "Dr. Drang", | ||
"email": "drdrang@gmail.com" | ||
} | ||
@@ -253,3 +265,3 @@ ], | ||
], | ||
"version": "7.2.0", | ||
"version": "7.3.0", | ||
"scripts": {}, | ||
@@ -256,0 +268,0 @@ "keywords": [ |
@@ -20,3 +20,3 @@ module.exports = function(hljs) { | ||
'ioctl socket readlink eval xor readline binmode setservent eof ord bind alarm pipe ' + | ||
'atan2 getgrent exp time push setgrent gt lt or ne m|0'; | ||
'atan2 getgrent exp time push setgrent gt lt or ne m|0 break given say state when'; | ||
var SUBST = { | ||
@@ -23,0 +23,0 @@ className: 'subst', |
@@ -19,6 +19,3 @@ module.exports = function(hljs) { | ||
]; | ||
var NUMBERS = [ | ||
hljs.C_NUMBER_MODE, // 0x..., 0..., decimal, float | ||
hljs.BINARY_NUMBER_MODE // 0b... | ||
]; | ||
var NUMBERS = [hljs.BINARY_NUMBER_MODE, hljs.C_NUMBER_MODE]; | ||
var TITLE = { | ||
@@ -25,0 +22,0 @@ className: 'title', begin: hljs.UNDERSCORE_IDENT_RE |
module.exports = function(hljs) { | ||
var PROMPT = { | ||
className: 'prompt', begin: '^(>>>|\\.\\.\\.) ' | ||
} | ||
var STRINGS = [ | ||
@@ -6,2 +9,3 @@ { | ||
begin: '(u|b)?r?\'\'\'', end: '\'\'\'', | ||
contains: [PROMPT], | ||
relevance: 10 | ||
@@ -12,2 +16,3 @@ }, | ||
begin: '(u|b)?r?"""', end: '"""', | ||
contains: [PROMPT], | ||
relevance: 10 | ||
@@ -47,3 +52,3 @@ }, | ||
begin: '\\(', end: '\\)', | ||
contains: ['self', hljs.C_NUMBER_MODE].concat(STRINGS) | ||
contains: ['self', hljs.C_NUMBER_MODE, PROMPT].concat(STRINGS) | ||
}; | ||
@@ -68,2 +73,3 @@ var FUNC_CLASS_PROTO = { | ||
contains: STRINGS.concat([ | ||
PROMPT, | ||
hljs.HASH_COMMENT_MODE, | ||
@@ -70,0 +76,0 @@ hljs.inherit(FUNC_CLASS_PROTO, {className: 'function', keywords: 'def'}), |
@@ -147,6 +147,11 @@ module.exports = function(hljs) { | ||
begin: ':', | ||
contains: STRINGS.concat([{begin: RUBY_IDENT_RE}]), | ||
contains: STRINGS.concat([{begin: RUBY_METHOD_RE}]), | ||
relevance: 0 | ||
}, | ||
{ | ||
className: 'symbol', | ||
begin: RUBY_IDENT_RE + ':', | ||
relevance: 0 | ||
}, | ||
{ | ||
className: 'number', | ||
@@ -171,3 +176,3 @@ begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b', | ||
illegal: '\\n', | ||
contains: [hljs.BACKSLASH_ESCAPE] | ||
contains: [hljs.BACKSLASH_ESCAPE, SUBST] | ||
} | ||
@@ -174,0 +179,0 @@ ]), |
@@ -6,8 +6,2 @@ module.exports = function(hljs) { | ||
}; | ||
var QUOTE_STRING = { | ||
className: 'string', | ||
begin: '"', end: '"', | ||
contains: [hljs.BACKSLASH_ESCAPE], | ||
relevance: 0 | ||
}; | ||
var NUMBER = { | ||
@@ -29,3 +23,3 @@ className: 'number', | ||
hljs.C_BLOCK_COMMENT_MODE, | ||
QUOTE_STRING, | ||
hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}), | ||
hljs.APOS_STRING_MODE, | ||
@@ -32,0 +26,0 @@ NUMBER, |
module.exports = function(hljs) { | ||
return { | ||
case_insensitive: true, | ||
illegal: '[^\\s]', | ||
contains: [ | ||
{ | ||
className: 'operator', | ||
begin: '(begin|start|commit|rollback|savepoint|lock|alter|create|drop|rename|call|delete|do|handler|insert|load|replace|select|truncate|update|set|show|pragma|grant)\\b', end: ';', endsWithParent: true, | ||
begin: '(begin|start|commit|rollback|savepoint|lock|alter|create|drop|rename|call|delete|do|handler|insert|load|replace|select|truncate|update|set|show|pragma|grant)\\b(?!:)', // negative look-ahead here is specifically to prevent stomping on SmallTalk | ||
end: ';', endsWithParent: true, | ||
keywords: { | ||
@@ -29,3 +29,3 @@ keyword: 'all partial global month current_timestamp using go revoke smallint ' + | ||
'work order cascade diagnostics nchar having left call do handler load replace ' + | ||
'truncate start lock show pragma', | ||
'truncate start lock show pragma exists number', | ||
aggregate: 'count sum min max avg' | ||
@@ -32,0 +32,0 @@ }, |
@@ -26,9 +26,3 @@ module.exports = function(hljs) { | ||
contains: [ | ||
{ // can’t use standard QUOTE_STRING_MODE since it’s compiled with its own escape and doesn’t use the local one | ||
className: 'string', | ||
begin: '"', end: '"', | ||
illegal: '\\n', | ||
contains: [{begin: '""'}], | ||
relevance: 0 | ||
}, | ||
hljs.inherit(hljs.QUOTE_STRING_MODE, {contains: [{begin: '""'}]}), | ||
{ | ||
@@ -35,0 +29,0 @@ className: 'comment', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171531
56
4516