update
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
Syntax highlighting with language autodetection.
|
||||
|
||||
URL: http://softwaremaniacs.org/soft/highlight/en/
|
||||
|
||||
Original author and current maintainer:
|
||||
Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
|
||||
|
||||
Contributors:
|
||||
|
||||
- Peter Leonov <gojpeg@gmail.com>
|
||||
- Victor Karamzin <Victor.Karamzin@enterra-inc.com>
|
||||
- Vsevolod Solovyov <vsevolod.solovyov@gmail.com>
|
||||
- Anton Kovalyov <anton@kovalyov.net>
|
||||
- Nikita Ledyaev <lenikita@yandex.ru>
|
||||
- Konstantin Evdokimenko <qewerty@gmail.com>
|
||||
- Dmitri Roudakov <dmitri@roudakov.ru>
|
||||
- Yuri Ivanov <ivanov@supersoft.ru>
|
||||
- Vladimir Ermakov <vooon341@mail.ru>
|
||||
- Vladimir Gubarkov <xonixx@gmail.com>
|
||||
- Brian Beck <exogen@gmail.com>
|
||||
- MajestiC <majestic2k@gmail.com>
|
||||
- Vasily Polovnyov <vast@whiteants.net>
|
||||
- Vladimir Epifanov <voldmar@voldmar.ru>
|
||||
- Alexander Makarov (http://rmcreative.ru/)
|
||||
- Vah <vahtenberg@gmail.com>
|
||||
- Shuen-Huei Guan <drake.guan@gmail.com>
|
||||
- Jason Diamond <jason@diamond.name>
|
||||
- Michal Gabrukiewicz <mgabru@gmail.com>
|
||||
- Ruslan Keba <rukeba@gmail.com>
|
||||
- Sergey Baranov <segyrn@yandex.ru>
|
||||
- Zaripov Yura <yur4ik7@ukr.net>
|
||||
- Oleg Volchkov <oleg@volchkov.net>
|
||||
- Vasily Mikhailitchenko <vaskas@programica.ru>
|
||||
- Jan Berkel <jan.berkel@gmail.com>
|
||||
- Vladimir Moskva <vladmos@gmail.com>
|
||||
- Loren Segal <lsegal@soen.ca>
|
||||
- Andrew Fedorov <dmmdrs@mail.ru>
|
||||
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2006, Ivan Sagalaev
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of highlight.js nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -0,0 +1,115 @@
|
||||
<!-- saved from url=(0013)about:internet -->
|
||||
<!-- ^^^ This is for IE not to show security warning for local files,
|
||||
see http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2brows.mspx-->
|
||||
|
||||
<!--
|
||||
Highlighted code export
|
||||
Copyright (c) Vladimir Gubarkov <xonixx@gmail.com>
|
||||
-->
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Highlited code export</title>
|
||||
<link rel="stylesheet" href="styles/default.css">
|
||||
<meta charset="utf-8">
|
||||
<style type="text/css">
|
||||
#t1, #t2 { width: 100%;}
|
||||
tr { vertical-align: top; }
|
||||
address { margin-top: 4em; }
|
||||
</style>
|
||||
<script src="highlight.js"></script>
|
||||
<script src="languages/cs.js"></script>
|
||||
<script src="languages/python.js"></script>
|
||||
<script src="languages/mel.js"></script>
|
||||
<script src="languages/perl.js"></script>
|
||||
<script src="languages/axapta.js"></script>
|
||||
<script src="languages/cpp.js"></script>
|
||||
<script src="languages/sql.js"></script>
|
||||
<script src="languages/smalltalk.js"></script>
|
||||
<script src="languages/profile.js"></script>
|
||||
<script src="languages/bash.js"></script>
|
||||
<script src="languages/html-xml.js"></script>
|
||||
<script src="languages/renderman.js"></script>
|
||||
<script src="languages/1c.js"></script>
|
||||
<script src="languages/delphi.js"></script>
|
||||
<script src="languages/dos.js"></script>
|
||||
<script src="languages/django.js"></script>
|
||||
<script src="languages/vbscript.js"></script>
|
||||
<script src="languages/ini.js"></script>
|
||||
<script src="languages/apache.js"></script>
|
||||
<script src="languages/ruby.js"></script>
|
||||
<script src="languages/css.js"></script>
|
||||
<script src="languages/lisp.js"></script>
|
||||
<script src="languages/java.js"></script>
|
||||
<script src="languages/javascript.js"></script>
|
||||
<script src="languages/php.js"></script>
|
||||
<script src="languages/diff.js"></script>
|
||||
<script src="languages/avrasm.js"></script>
|
||||
<script src="languages/parser3.js"></script>
|
||||
<script>hljs.initHighlightingOnLoad();</script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
String.prototype.escape = function() {
|
||||
return this.replace(/&/gm, '&').replace(/</gm, '<').replace(/>/gm, '>');
|
||||
}
|
||||
|
||||
function doIt() {
|
||||
var viewDiv = document.getElementById("highlight-view");
|
||||
var t1 = document.getElementById("t1");
|
||||
var t2 = document.getElementById("t2");
|
||||
var selector = document.getElementById("langSelector");
|
||||
var selectedLang = selector.options[selector.selectedIndex].value.toLowerCase();
|
||||
if(selectedLang) {
|
||||
viewDiv.innerHTML = '<pre><code class="'+selectedLang+'">'+t1.value.escape()+"</code></pre>";
|
||||
} else { // try auto
|
||||
viewDiv.innerHTML = '<pre><code>' + t1.value.escape() + "</code></pre>";
|
||||
}
|
||||
hljs.highlightBlock(viewDiv.firstChild.firstChild);
|
||||
t2.value = viewDiv.innerHTML;
|
||||
}
|
||||
|
||||
function copyToBuffer(textToCopy) {
|
||||
if (window.clipboardData) { // IE
|
||||
window.clipboardData.setData("Text", textToCopy);
|
||||
} else if (window.netscape) { // FF
|
||||
// from http://developer.mozilla.org/en/docs/Using_the_Clipboard
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var gClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper);
|
||||
gClipboardHelper.copyString(textToCopy);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var langSelectorHtml = '<label>Language <select id="langSelector">';
|
||||
langSelectorHtml += '<option value="">Auto</option>';
|
||||
for (var i in hljs.LANGUAGES) {
|
||||
if (hljs.LANGUAGES.hasOwnProperty(i))
|
||||
langSelectorHtml += '<option value=\"'+i+'\">'+i.charAt(0).toUpperCase()+i.substr(1)+'</option>';
|
||||
}
|
||||
langSelectorHtml += '</select></label>';
|
||||
document.write(langSelectorHtml);
|
||||
</script>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td><textarea rows="20" cols="50" id="t1"></textarea></td>
|
||||
<td><textarea rows="20" cols="50" id="t2"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Write a code snippet</td>
|
||||
<td>Get HTML to paste anywhere (for actual styles and colors see sample.css)</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="98%">
|
||||
<tr>
|
||||
<td><input type="button" value="Export →" onclick="doIt()"/></td>
|
||||
<td align="right"><input type="button" value="Copy to buffer" onclick="copyToBuffer(document.getElementById('t2').value);"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="highlight-view"></div>
|
||||
<address>
|
||||
Export script: <a href="mailto:xonixx@gmail.com">Vladimir Gubarkov</a><br>
|
||||
Highlighting: <a href="http://softwaremaniacs.org/soft/highlight/">highlight.js</a>
|
||||
</address>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,578 @@
|
||||
/*
|
||||
Syntax highlighting with language autodetection.
|
||||
http://softwaremaniacs.org/soft/highlight/
|
||||
*/
|
||||
|
||||
var hljs = new function() {
|
||||
var LANGUAGES = {};
|
||||
var selected_languages = {};
|
||||
function escape(value) {
|
||||
return value.replace(/&/gm, '&').replace(/</gm, '<').replace(/>/gm, '>');
|
||||
};
|
||||
|
||||
function contains(array, item) {
|
||||
if (!array)
|
||||
return false;
|
||||
for (var i = 0; i < array.length; i++)
|
||||
if (array[i] == item) return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
function langRe(language, value, global) {
|
||||
var mode = 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '');
|
||||
return new RegExp(value, mode);
|
||||
};
|
||||
|
||||
function findCode(pre) {
|
||||
var node;
|
||||
for (var i = 0; i < pre.childNodes.length; i++) {
|
||||
node = pre.childNodes[i];
|
||||
if (node.nodeName == 'CODE')
|
||||
return node;
|
||||
if (!(node.nodeType == 3 && node.nodeValue.match(/\s+/)))
|
||||
return null;
|
||||
};
|
||||
};
|
||||
|
||||
function blockText(block) {
|
||||
var result = '';
|
||||
for (var i = 0; i < block.childNodes.length; i++)
|
||||
if (block.childNodes[i].nodeType == 3)
|
||||
result += block.childNodes[i].nodeValue;
|
||||
else if (block.childNodes[i].nodeName == 'BR')
|
||||
result += '\n';
|
||||
else
|
||||
result += blockText(block.childNodes[i]);
|
||||
return result;
|
||||
};
|
||||
|
||||
function blockLanguage(block) {
|
||||
var classes = block.className.split(/\s+/);
|
||||
classes = classes.concat(block.parentNode.className.split(/\s+/));
|
||||
for (var i = 0; i < classes.length; i++) {
|
||||
var class_ = classes[i].replace(/^language-/, '');
|
||||
if (class_ == 'no-highlight') {
|
||||
throw 'No highlight'
|
||||
};
|
||||
if (LANGUAGES[class_]) {
|
||||
return class_;
|
||||
};
|
||||
};
|
||||
};
|
||||
function nodeStream(node) {
|
||||
var result = [];
|
||||
(function (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')
|
||||
offset += 1;
|
||||
else {
|
||||
result.push({
|
||||
event: 'start',
|
||||
offset: offset,
|
||||
node: node.childNodes[i]
|
||||
});
|
||||
offset = arguments.callee(node.childNodes[i], offset);
|
||||
result.push({
|
||||
event: 'stop',
|
||||
offset: offset,
|
||||
node: node.childNodes[i]
|
||||
});
|
||||
};
|
||||
};
|
||||
return offset;
|
||||
})(node, 0);
|
||||
return result;
|
||||
};
|
||||
|
||||
function mergeStreams(stream1, stream2, value) {
|
||||
var processed = 0;
|
||||
var result = '';
|
||||
var nodeStack = [];
|
||||
|
||||
function selectStream() {
|
||||
if (stream1.length && stream2.length) {
|
||||
if (stream1[0].offset != stream2[0].offset)
|
||||
return (stream1[0].offset < stream2[0].offset) ? stream1 : stream2;
|
||||
else
|
||||
return (stream1[0].event == 'start' && stream2[0].event == 'stop') ? stream2 : stream1;
|
||||
} else {
|
||||
return stream1.length ? stream1 : stream2;
|
||||
};
|
||||
};
|
||||
|
||||
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.nodeValue != undefined) {
|
||||
result += '="' + escape(attribute.nodeValue) + '"';
|
||||
};
|
||||
};
|
||||
return result + '>';
|
||||
};
|
||||
|
||||
function close(node) {
|
||||
return '</' + node.nodeName.toLowerCase() + '>';
|
||||
};
|
||||
|
||||
while (stream1.length || stream2.length) {
|
||||
var current = selectStream().splice(0, 1)[0];
|
||||
result += escape(value.substr(processed, current.offset - processed));
|
||||
processed = current.offset;
|
||||
if ( current.event == 'start') {
|
||||
result += open(current.node);
|
||||
nodeStack.push(current.node);
|
||||
} else if (current.event == 'stop') {
|
||||
var i = nodeStack.length;
|
||||
do {
|
||||
i--;
|
||||
var node = nodeStack[i];
|
||||
result += close(node);
|
||||
} while (node != current.node);
|
||||
nodeStack.splice(i, 1);
|
||||
while (i < nodeStack.length) {
|
||||
result += open(nodeStack[i]);
|
||||
i++;
|
||||
};
|
||||
};
|
||||
};
|
||||
result += value.substr(processed);
|
||||
return result;
|
||||
};
|
||||
function highlight(language_name, value) {
|
||||
function compileSubModes(mode, language) {
|
||||
mode.sub_modes = [];
|
||||
for (var i = 0; i < mode.contains.length; i++) {
|
||||
for (var j = 0; j < language.modes.length; j++) {
|
||||
if (language.modes[j].className == mode.contains[i]) {
|
||||
mode.sub_modes[mode.sub_modes.length] = language.modes[j];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
function subMode(lexem, mode) {
|
||||
if (!mode.contains) {
|
||||
return null;
|
||||
};
|
||||
if (!mode.sub_modes) {
|
||||
compileSubModes(mode, language);
|
||||
};
|
||||
for (var i = 0; i < mode.sub_modes.length; i++) {
|
||||
if (mode.sub_modes[i].beginRe.test(lexem)) {
|
||||
return mode.sub_modes[i];
|
||||
};
|
||||
};
|
||||
return null;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
|
||||
function isIllegal(lexem, mode) {
|
||||
return mode.illegalRe && mode.illegalRe.test(lexem);
|
||||
};
|
||||
|
||||
function compileTerminators(mode, language) {
|
||||
var terminators = [];
|
||||
|
||||
function addTerminator(re) {
|
||||
if (!contains(terminators, re)) {
|
||||
terminators[terminators.length] = re;
|
||||
};
|
||||
};
|
||||
|
||||
if (mode.contains)
|
||||
for (var i = 0; i < language.modes.length; i++) {
|
||||
if (contains(mode.contains, language.modes[i].className)) {
|
||||
addTerminator(language.modes[i].begin);
|
||||
};
|
||||
};
|
||||
|
||||
var index = modes.length - 1;
|
||||
do {
|
||||
if (modes[index].end) {
|
||||
addTerminator(modes[index].end);
|
||||
};
|
||||
index--;
|
||||
} while (modes[index + 1].endsWithParent);
|
||||
|
||||
if (mode.illegal) {
|
||||
addTerminator(mode.illegal);
|
||||
};
|
||||
|
||||
var terminator_re = '(' + terminators[0];
|
||||
for (var i = 0; i < terminators.length; i++)
|
||||
terminator_re += '|' + terminators[i];
|
||||
terminator_re += ')';
|
||||
return langRe(language, terminator_re);
|
||||
};
|
||||
|
||||
function eatModeChunk(value, index) {
|
||||
var mode = modes[modes.length - 1];
|
||||
if (!mode.terminators) {
|
||||
mode.terminators = compileTerminators(mode, language);
|
||||
};
|
||||
value = value.substr(index);
|
||||
var match = mode.terminators.exec(value);
|
||||
if (!match)
|
||||
return [value, '', true];
|
||||
if (match.index == 0)
|
||||
return ['', match[0], false];
|
||||
else
|
||||
return [value.substr(0, match.index), match[0], false];
|
||||
};
|
||||
|
||||
function keywordMatch(mode, match) {
|
||||
var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0];
|
||||
for (var className in mode.keywordGroups) {
|
||||
if (!mode.keywordGroups.hasOwnProperty(className))
|
||||
continue;
|
||||
var value = mode.keywordGroups[className].hasOwnProperty(match_str);
|
||||
if (value)
|
||||
return [className, value];
|
||||
};
|
||||
return false;
|
||||
};
|
||||
|
||||
function processKeywords(buffer, mode) {
|
||||
if (!mode.keywords || !mode.lexems)
|
||||
return escape(buffer);
|
||||
if (!mode.lexemsRe) {
|
||||
var lexems_re = '(' + mode.lexems[0];
|
||||
for (var i = 1; i < mode.lexems.length; i++)
|
||||
lexems_re += '|' + mode.lexems[i];
|
||||
lexems_re += ')';
|
||||
mode.lexemsRe = langRe(language, lexems_re, true);
|
||||
};
|
||||
var result = '';
|
||||
var last_index = 0;
|
||||
mode.lexemsRe.lastIndex = 0;
|
||||
var match = mode.lexemsRe.exec(buffer);
|
||||
while (match) {
|
||||
result += escape(buffer.substr(last_index, match.index - last_index));
|
||||
var keyword_match = keywordMatch(mode, match);
|
||||
if (keyword_match) {
|
||||
keyword_count += keyword_match[1];
|
||||
result += '<span class="'+ keyword_match[0] +'">' + escape(match[0]) + '</span>';
|
||||
} else {
|
||||
result += escape(match[0]);
|
||||
};
|
||||
last_index = mode.lexemsRe.lastIndex;
|
||||
match = mode.lexemsRe.exec(buffer);
|
||||
};
|
||||
result += escape(buffer.substr(last_index, buffer.length - last_index));
|
||||
return result;
|
||||
};
|
||||
|
||||
function processBuffer(buffer, mode) {
|
||||
if (mode.subLanguage && selected_languages[mode.subLanguage]) {
|
||||
var result = highlight(mode.subLanguage, buffer);
|
||||
keyword_count += result.keyword_count;
|
||||
relevance += result.relevance;
|
||||
return result.value;
|
||||
} else {
|
||||
return processKeywords(buffer, mode);
|
||||
};
|
||||
};
|
||||
|
||||
function startNewMode(mode, lexem) {
|
||||
var markup = mode.noMarkup?'':'<span class="' + mode.displayClassName + '">';
|
||||
if (mode.returnBegin) {
|
||||
result += markup;
|
||||
mode.buffer = '';
|
||||
} else if (mode.excludeBegin) {
|
||||
result += escape(lexem) + markup;
|
||||
mode.buffer = '';
|
||||
} else {
|
||||
result += markup;
|
||||
mode.buffer = lexem;
|
||||
};
|
||||
modes[modes.length] = mode;
|
||||
};
|
||||
|
||||
function processModeInfo(buffer, lexem, end) {
|
||||
var current_mode = modes[modes.length - 1];
|
||||
if (end) {
|
||||
result += processBuffer(current_mode.buffer + buffer, current_mode);
|
||||
return false;
|
||||
};
|
||||
|
||||
var new_mode = subMode(lexem, current_mode);
|
||||
if (new_mode) {
|
||||
result += processBuffer(current_mode.buffer + buffer, current_mode);
|
||||
startNewMode(new_mode, lexem);
|
||||
relevance += new_mode.relevance;
|
||||
return new_mode.returnBegin;
|
||||
};
|
||||
|
||||
var end_level = endOfMode(modes.length - 1, lexem);
|
||||
if (end_level) {
|
||||
var markup = current_mode.noMarkup?'':'</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;
|
||||
};
|
||||
while (end_level > 1) {
|
||||
markup = modes[modes.length - 2].noMarkup?'':'</span>';
|
||||
result += markup;
|
||||
end_level--;
|
||||
modes.length--;
|
||||
};
|
||||
modes.length--;
|
||||
modes[modes.length - 1].buffer = '';
|
||||
if (current_mode.starts) {
|
||||
for (var i = 0; i < language.modes.length; i++) {
|
||||
if (language.modes[i].className == current_mode.starts) {
|
||||
startNewMode(language.modes[i], '');
|
||||
break;
|
||||
};
|
||||
};
|
||||
};
|
||||
return current_mode.returnEnd;
|
||||
};
|
||||
|
||||
if (isIllegal(lexem, current_mode))
|
||||
throw 'Illegal';
|
||||
};
|
||||
|
||||
var language = LANGUAGES[language_name];
|
||||
var modes = [language.defaultMode];
|
||||
var relevance = 0;
|
||||
var keyword_count = 0;
|
||||
var result = '';
|
||||
try {
|
||||
var index = 0;
|
||||
language.defaultMode.buffer = '';
|
||||
do {
|
||||
var mode_info = eatModeChunk(value, index);
|
||||
var return_lexem = processModeInfo(mode_info[0], mode_info[1], mode_info[2]);
|
||||
index += mode_info[0].length;
|
||||
if (!return_lexem) {
|
||||
index += mode_info[1].length;
|
||||
};
|
||||
} while (!mode_info[2]);
|
||||
if(modes.length > 1)
|
||||
throw 'Illegal';
|
||||
return {
|
||||
relevance: relevance,
|
||||
keyword_count: keyword_count,
|
||||
value: result
|
||||
};
|
||||
} catch (e) {
|
||||
if (e == 'Illegal') {
|
||||
return {
|
||||
relevance: 0,
|
||||
keyword_count: 0,
|
||||
value: escape(value)
|
||||
};
|
||||
} else {
|
||||
throw e;
|
||||
};
|
||||
};
|
||||
};
|
||||
function compileModes() {
|
||||
for (var i in LANGUAGES) {
|
||||
if (!LANGUAGES.hasOwnProperty(i))
|
||||
continue;
|
||||
var language = LANGUAGES[i];
|
||||
for (var j = 0; j < language.modes.length; j++) {
|
||||
var mode = language.modes[j];
|
||||
if (mode.begin)
|
||||
mode.beginRe = langRe(language, '^' + mode.begin);
|
||||
if (mode.end)
|
||||
mode.endRe = langRe(language, '^' + mode.end);
|
||||
if (mode.illegal)
|
||||
mode.illegalRe = langRe(language, '^(?:' + mode.illegal + ')');
|
||||
language.defaultMode.illegalRe = langRe(language, '^(?:' + language.defaultMode.illegal + ')');
|
||||
if (mode.relevance == undefined) {
|
||||
mode.relevance = 1;
|
||||
};
|
||||
if (!mode.displayClassName) {
|
||||
mode.displayClassName = mode.className;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
function compileKeywords() {
|
||||
|
||||
function compileModeKeywords(mode) {
|
||||
if (!mode.keywordGroups) {
|
||||
for (var key in mode.keywords) {
|
||||
if (!mode.keywords.hasOwnProperty(key))
|
||||
continue;
|
||||
if (mode.keywords[key] instanceof Object)
|
||||
mode.keywordGroups = mode.keywords;
|
||||
else
|
||||
mode.keywordGroups = {'keyword': mode.keywords};
|
||||
break;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
for (var i in LANGUAGES) {
|
||||
if (!LANGUAGES.hasOwnProperty(i))
|
||||
continue;
|
||||
var language = LANGUAGES[i];
|
||||
compileModeKeywords(language.defaultMode);
|
||||
for (var j = 0; j < language.modes.length; j++) {
|
||||
compileModeKeywords(language.modes[j]);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
function initialize() {
|
||||
if (initialize.called)
|
||||
return;
|
||||
initialize.called = true;
|
||||
compileModes();
|
||||
compileKeywords();
|
||||
selected_languages = LANGUAGES;
|
||||
};
|
||||
function highlightBlock(block, tabReplace) {
|
||||
initialize();
|
||||
|
||||
try {
|
||||
var text = blockText(block);
|
||||
var language = blockLanguage(block);
|
||||
} catch (e) {
|
||||
if (e == 'No highlight')
|
||||
return;
|
||||
};
|
||||
|
||||
if (language) {
|
||||
var result = highlight(language, text).value;
|
||||
} else {
|
||||
var max_relevance = 0;
|
||||
for (var key in selected_languages) {
|
||||
if (!selected_languages.hasOwnProperty(key))
|
||||
continue;
|
||||
var lang_result = highlight(key, text);
|
||||
var relevance = lang_result.keyword_count + lang_result.relevance;
|
||||
if (relevance > max_relevance) {
|
||||
max_relevance = relevance;
|
||||
var result = lang_result.value;
|
||||
language = key;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
if (result) {
|
||||
var class_name = block.className;
|
||||
if (!class_name.match(language)) {
|
||||
class_name += ' ' + language;
|
||||
};
|
||||
var original = nodeStream(block);
|
||||
if (original.length) {
|
||||
var pre = document.createElement('pre');
|
||||
pre.innerHTML = result;
|
||||
result = mergeStreams(original, nodeStream(pre), text);
|
||||
};
|
||||
if (tabReplace) {
|
||||
result = result.replace(/^((<[^>]+>|\t)+)/gm, function(match, p1, offset, s) {
|
||||
return p1.replace(/\t/g, tabReplace);
|
||||
});
|
||||
};
|
||||
var container = document.createElement('div');
|
||||
container.innerHTML = '<pre><code class="' + class_name + '">' + result + '</code></pre>';
|
||||
var environment = block.parentNode.parentNode;
|
||||
environment.replaceChild(container.firstChild, block.parentNode);
|
||||
};
|
||||
};
|
||||
|
||||
function initHighlighting() {
|
||||
if (initHighlighting.called)
|
||||
return;
|
||||
initHighlighting.called = true;
|
||||
initialize();
|
||||
if (arguments.length) {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (LANGUAGES[arguments[i]]) {
|
||||
selected_languages[arguments[i]] = LANGUAGES[arguments[i]];
|
||||
};
|
||||
};
|
||||
};
|
||||
var pres = document.getElementsByTagName('pre');
|
||||
for (var i = 0; i < pres.length; i++) {
|
||||
var code = findCode(pres[i]);
|
||||
if (code)
|
||||
highlightBlock(code, hljs.tabReplace);
|
||||
};
|
||||
};
|
||||
|
||||
function initHighlightingOnLoad() {
|
||||
var original_arguments = arguments;
|
||||
var handler = function(){initHighlighting.apply(null, original_arguments)};
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('DOMContentLoaded', handler, false);
|
||||
window.addEventListener('load', handler, false);
|
||||
} else if (window.attachEvent)
|
||||
window.attachEvent('onload', handler);
|
||||
else
|
||||
window.onload = handler;
|
||||
};
|
||||
this.LANGUAGES = LANGUAGES;
|
||||
this.initHighlightingOnLoad = initHighlightingOnLoad;
|
||||
this.highlightBlock = highlightBlock;
|
||||
this.initHighlighting = initHighlighting;
|
||||
|
||||
this.IDENT_RE = '[a-zA-Z][a-zA-Z0-9_]*';
|
||||
this.UNDERSCORE_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_]*';
|
||||
this.NUMBER_RE = '\\b\\d+(\\.\\d+)?';
|
||||
this.C_NUMBER_RE = '\\b(0x[A-Za-z0-9]+|\\d+(\\.\\d+)?)';
|
||||
this.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';
|
||||
|
||||
this.APOS_STRING_MODE = {
|
||||
className: 'string',
|
||||
begin: '\'', end: '\'',
|
||||
illegal: '\\n',
|
||||
contains: ['escape'],
|
||||
relevance: 0
|
||||
};
|
||||
this.QUOTE_STRING_MODE = {
|
||||
className: 'string',
|
||||
begin: '"', end: '"',
|
||||
illegal: '\\n',
|
||||
contains: ['escape'],
|
||||
relevance: 0
|
||||
};
|
||||
this.BACKSLASH_ESCAPE = {
|
||||
className: 'escape',
|
||||
begin: '\\\\.', end: '^', noMarkup: true,
|
||||
relevance: 0
|
||||
};
|
||||
this.C_LINE_COMMENT_MODE = {
|
||||
className: 'comment',
|
||||
begin: '//', end: '$',
|
||||
relevance: 0
|
||||
};
|
||||
this.C_BLOCK_COMMENT_MODE = {
|
||||
className: 'comment',
|
||||
begin: '/\\*', end: '\\*/'
|
||||
};
|
||||
this.HASH_COMMENT_MODE = {
|
||||
className: 'comment',
|
||||
begin: '#', end: '$'
|
||||
};
|
||||
this.C_NUMBER_MODE = {
|
||||
className: 'number',
|
||||
begin: this.C_NUMBER_RE, end: '^',
|
||||
relevance: 0
|
||||
};
|
||||
}();
|
||||
|
||||
var initHighlightingOnLoad = hljs.initHighlightingOnLoad;
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Language: Javascript
|
||||
*/
|
||||
|
||||
hljs.LANGUAGES.javascript = {
|
||||
defaultMode: {
|
||||
lexems: [hljs.UNDERSCORE_IDENT_RE],
|
||||
contains: ['string', 'comment', 'number', 'regexp_container', 'function'],
|
||||
keywords: {
|
||||
'keyword': {'in': 1, 'if': 1, 'for': 1, 'while': 1, 'finally': 1, 'var': 1, 'new': 1, 'function': 1, 'do': 1, 'return': 1, 'void': 1, 'else': 1, 'break': 1, 'catch': 1, 'instanceof': 1, 'with': 1, 'throw': 1, 'case': 1, 'default': 1, 'try': 1, 'this': 1, 'switch': 1, 'continue': 1, 'typeof': 1, 'delete': 1},
|
||||
'literal': {'true': 1, 'false': 1, 'null': 1}
|
||||
}
|
||||
},
|
||||
modes: [
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
hljs.C_NUMBER_MODE,
|
||||
hljs.APOS_STRING_MODE,
|
||||
hljs.QUOTE_STRING_MODE,
|
||||
hljs.BACKSLASH_ESCAPE,
|
||||
{
|
||||
className: 'regexp_container',
|
||||
begin: '(' + hljs.RE_STARTERS_RE + '|case|return|throw)\\s*', end: '^', noMarkup: true,
|
||||
lexems: [hljs.IDENT_RE],
|
||||
keywords: {'return': 1, 'throw': 1, 'case': 1},
|
||||
contains: ['comment', 'regexp'],
|
||||
relevance: 0
|
||||
},
|
||||
{
|
||||
className: 'regexp',
|
||||
begin: '/.*?[^\\\\/]/[gim]*', end: '^'
|
||||
},
|
||||
{
|
||||
className: 'function',
|
||||
begin: '\\bfunction\\b', end: '{',
|
||||
lexems: [hljs.UNDERSCORE_IDENT_RE],
|
||||
keywords: {'function': 1},
|
||||
contains: ['title', 'params']
|
||||
},
|
||||
{
|
||||
className: 'title',
|
||||
begin: '[A-Za-z$_][0-9A-Za-z$_]*', end: '^'
|
||||
},
|
||||
{
|
||||
className: 'params',
|
||||
begin: '\\(', end: '\\)',
|
||||
contains: ['string', 'comment']
|
||||
}
|
||||
]
|
||||
};
|
||||
@@ -0,0 +1,486 @@
|
||||
# Highlight.js
|
||||
|
||||
Highlight.js highlights syntax in code examples on blogs, forums and
|
||||
in fact on any web pages. It's very easy to use because it works
|
||||
automatically: finds blocks of code, detects a language, highlights it.
|
||||
|
||||
Autodetection can be fine tuned when it fails by itself (see "Heuristics").
|
||||
|
||||
|
||||
## Installation and usage
|
||||
|
||||
Downloaded package includes file "highlight.pack.js" which is a full compressed
|
||||
version of the library intended to use in production. All uncompressed source
|
||||
files are also available, feel free to look into them!
|
||||
|
||||
The script is installed by linking to a single file and making a single
|
||||
initialization call:
|
||||
|
||||
<script type="text/javascript" src="highlight.pack.js"></script>
|
||||
<script type="text/javascript">
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
|
||||
Also you can replaces TAB ('\x09') characters used for indentation in your code
|
||||
with some fixed number of spaces or with a `<span>` to set them special styling:
|
||||
|
||||
<script type="text/javascript">
|
||||
hljs.tabReplace = ' '; // 4 spaces
|
||||
// ... or
|
||||
hljs.tabReplace = '<span class="indent">\t</span>';
|
||||
|
||||
hljs.initHighlightingOnLoad();
|
||||
</script>
|
||||
|
||||
Then the script looks in your page for fragments `<pre><code>...</code></pre>`
|
||||
that are used traditionally to mark up code examples. Their content is
|
||||
marked up by logical pieces with defined class names.
|
||||
|
||||
|
||||
### Custom initialization
|
||||
|
||||
If you use different markup for code blocks you can initialize them manually
|
||||
with `highlightBlock(code, tabReplace)` function. It takes a DOM element
|
||||
containing the code to highlight and optionally a string with which to replace
|
||||
TAB characters.
|
||||
|
||||
Initialization using for example jQuery might look like this:
|
||||
|
||||
$(document).ready(function() {
|
||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
|
||||
});
|
||||
|
||||
|
||||
### Styling
|
||||
|
||||
Elements of code marked up with classes can be styled as desired:
|
||||
|
||||
.comment {
|
||||
color: gray;
|
||||
}
|
||||
|
||||
.keyword {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.python .string {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.html .atribute .value {
|
||||
color: green;
|
||||
}
|
||||
|
||||
Highligt.js comes with several style themes located in "styles" directory that
|
||||
can be used directly or as a base for your own experiments.
|
||||
|
||||
A full list of available classes is below ("Languages").
|
||||
|
||||
|
||||
## Export
|
||||
|
||||
File export.html contains a little program that shows and allows to copy and paste
|
||||
an HTML code generated by the highlighter for any code snippet. This can be useful
|
||||
in situations when one can't use the script itself on a site.
|
||||
|
||||
|
||||
## Languages
|
||||
|
||||
This is a full list of available classes corresponding to languages'
|
||||
syntactic structures. In parentheses after language names are identifiers
|
||||
used as class names in `<code>` element.
|
||||
|
||||
Python ("python"):
|
||||
|
||||
keyword keyword
|
||||
built_in built-in objects (None, False, True and Ellipsis)
|
||||
number number
|
||||
string string (of any type)
|
||||
comment comment
|
||||
decorator @-decorator for functions
|
||||
function function header "def some_name(...):"
|
||||
class class header "class SomeName(...):"
|
||||
title name of a function or a class inside a header
|
||||
params everything inside parentheses in a function's or class' header
|
||||
|
||||
Python profiler results ("profile"):
|
||||
|
||||
number number
|
||||
string string
|
||||
builtin builtin function entry
|
||||
filename filename in an entry
|
||||
summary profiling summary
|
||||
header header of table of results
|
||||
keyword column header
|
||||
function function name in an entry (including parentheses)
|
||||
title actual name of a function in an entry (excluding parentheses)
|
||||
|
||||
Ruby ("ruby"):
|
||||
|
||||
keyword keyword
|
||||
string string
|
||||
subst in-string substitution (#{...})
|
||||
comment comment
|
||||
yardoctag YARD tag
|
||||
function function header "def some_name(...):"
|
||||
class class header "class SomeName(...):"
|
||||
title name of a function or a class inside a header
|
||||
parent name of a parent class
|
||||
symbol symbol
|
||||
instancevar instance variable
|
||||
|
||||
Perl ("perl"):
|
||||
|
||||
keyword keyword
|
||||
comment comment
|
||||
number number
|
||||
string string
|
||||
regexp regular expression
|
||||
sub subroutine header (from "sub" till "{")
|
||||
variable variable starting with "$", "%", "@"
|
||||
operator operator
|
||||
pod plain old doc
|
||||
|
||||
PHP ("php"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string (of any type)
|
||||
comment comment
|
||||
phpdoc phpdoc params in comments
|
||||
variable variable starting with "$"
|
||||
preprocessor preprocessor marks: "<?php" and "?>"
|
||||
|
||||
Scala ("scala"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment comment
|
||||
annotaion annotation
|
||||
javadoc javadoc comment
|
||||
javadoctag @-tag in javadoc
|
||||
class class header
|
||||
title class name inside a header
|
||||
params everything in parentheses inside a class header
|
||||
inheritance keywords "extends" and "with" inside class header
|
||||
|
||||
XML ("xml"):
|
||||
|
||||
tag any tag from "<" till ">"
|
||||
comment comment
|
||||
pi processing instruction (<? ... ?>)
|
||||
cdata CDATA section
|
||||
attribute attribute
|
||||
value attribute's value
|
||||
|
||||
HTML ("html"):
|
||||
|
||||
keyword HTML tag
|
||||
tag any tag from "<" till ">"
|
||||
comment comment
|
||||
doctype <!DOCTYPE ... > declaration
|
||||
attribute tag's attribute with or without value
|
||||
value attribute's value
|
||||
|
||||
CSS ("css"):
|
||||
|
||||
keyword HTML tag when in selectors, CSS keyword when in rules
|
||||
id #some_name in selectors
|
||||
class .some_name in selectors
|
||||
at_rule @-rule till first "{" or ";"
|
||||
attr_selector attribute selector (square brackets in a[href^=http://])
|
||||
pseudo pseudo classes and elemens (:after, ::after etc.)
|
||||
comment comment
|
||||
rules everything from "{" till "}"
|
||||
value property's value inside a rule, from ":" till ";" or
|
||||
till the end of rule block
|
||||
number number within a value
|
||||
string string within a value
|
||||
hexcolor hex color (#FFFFFF) within a value
|
||||
function CSS function within a value
|
||||
params everything between "(" and ")" within a function
|
||||
|
||||
Django ("django"):
|
||||
|
||||
keyword HTML tag in HTML, default tags and default filters in templates
|
||||
tag any tag from "<" till ">"
|
||||
comment comment
|
||||
doctype <!DOCTYPE ... > declaration
|
||||
attribute tag's attribute with or withou value
|
||||
value attribute's value
|
||||
template_tag template tag {% .. %}
|
||||
variable template variable {{ .. }}
|
||||
template_comment template comment, both {# .. #} and {% comment %}
|
||||
filter filter from "|" till the next filter or the end of tag
|
||||
argument filter argument
|
||||
|
||||
Javascript ("javascript"):
|
||||
|
||||
keyword keyword
|
||||
comment comment
|
||||
number number
|
||||
literal special literal: "true", "false" and "null"
|
||||
string string
|
||||
regexp regular expression
|
||||
function header of a function
|
||||
title name of a function inside a header
|
||||
params everything inside parentheses in a function's header
|
||||
|
||||
VBScript ("vbscript"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment comment
|
||||
built_in built-in function
|
||||
|
||||
Lua ("lua"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment comment
|
||||
built_in built-in operator
|
||||
function header of a function
|
||||
title name of a function inside a header
|
||||
params everything inside parentheses in a function's header
|
||||
long_brackets multiline string in [=[ .. ]=]
|
||||
|
||||
Delphi ("delphi"):
|
||||
|
||||
keyword keyword
|
||||
comment comment (of any type)
|
||||
number number
|
||||
string string
|
||||
function header of a function, procedure, constructor and destructor
|
||||
title name of a function, procedure, constructor or destructor
|
||||
inside a header
|
||||
params everything inside parentheses in a function's header
|
||||
class class' body from "= class" till "end;"
|
||||
|
||||
Java ("java"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment commment
|
||||
annotaion annotation
|
||||
javadoc javadoc comment
|
||||
class class header from "class" till "{"
|
||||
title class name inside a header
|
||||
params everything in parentheses inside a class header
|
||||
inheritance keywords "extends" and "implements" inside class header
|
||||
|
||||
C++ ("cpp"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string and character
|
||||
comment comment
|
||||
preprocessor preprocessor directive
|
||||
stl_container instantiation of STL containers ("vector<...>")
|
||||
|
||||
C# ("cs"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment commment
|
||||
xmlDocTag xmldoc tag ("///", "<!--", "-->", "<..>")
|
||||
|
||||
RenderMan RSL ("rsl"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string (including @"..")
|
||||
comment comment
|
||||
preprocessor preprocessor directive
|
||||
shader sahder keywords
|
||||
shading shading keywords
|
||||
built_in built-in function
|
||||
|
||||
RenderMan RIB ("rib"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment comment
|
||||
commands command
|
||||
|
||||
Maya Embedded Language ("mel"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment comment
|
||||
variable variable
|
||||
|
||||
SQL ("sql"):
|
||||
|
||||
keyword keyword (mostly SQL'92 and SQL'99)
|
||||
number number
|
||||
string string (of any type: "..", '..', `..`)
|
||||
comment comment
|
||||
aggregate aggregate function
|
||||
|
||||
Smalltalk ("smalltalk"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment commment
|
||||
symbol symbol
|
||||
array array
|
||||
class name of a class
|
||||
char char
|
||||
localvars block of local variables
|
||||
|
||||
Lisp ("lisp"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment commment
|
||||
variable variable
|
||||
literal b, t and nil
|
||||
list non-quoted list
|
||||
title first symbol in a non-quoted list
|
||||
body remainder of the non-quoted list
|
||||
quoted_list quoted list, both "(quote .. )" and "'(..)"
|
||||
|
||||
Ini ("ini"):
|
||||
|
||||
title title of a section
|
||||
value value of a setting of any type
|
||||
string string
|
||||
number number
|
||||
keyword boolean value keyword
|
||||
|
||||
Apache ("apache"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
comment commment
|
||||
literal On and Off
|
||||
sqbracket variables in rewrites "%{..}"
|
||||
cbracket options in rewrites "[..]"
|
||||
tag begin and end of a configuration section
|
||||
|
||||
Nginx ("nginx"):
|
||||
|
||||
keyword keyword
|
||||
string string
|
||||
number number
|
||||
comment comment
|
||||
built_in built-in constant
|
||||
variable $-variable
|
||||
|
||||
DOS ("dos"):
|
||||
|
||||
keyword keyword
|
||||
flow batch control keyword
|
||||
stream DOS special files ("con", "prn", ...)
|
||||
winutils some commands (see dos.js specifically)
|
||||
envvar environment variables
|
||||
|
||||
Bash ("bash"):
|
||||
|
||||
keyword keyword
|
||||
string string
|
||||
number number
|
||||
comment comment
|
||||
literal special literal: "true" и "false"
|
||||
variable variable
|
||||
shebang script interpreter header
|
||||
|
||||
Diff ("diff"):
|
||||
|
||||
header file header
|
||||
chunk chunk header within a file
|
||||
addition added lines
|
||||
deletion deleted lines
|
||||
change changed lines
|
||||
|
||||
Axapta ("axapta"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
string string
|
||||
comment commment
|
||||
class class header from "class" till "{"
|
||||
title class name inside a header
|
||||
params everything in parentheses inside a class header
|
||||
inheritance keywords "extends" and "implements" inside class header
|
||||
preprocessor preprocessor directive
|
||||
|
||||
1C ("1c"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
date date
|
||||
string string
|
||||
comment commment
|
||||
function header of function or procudure
|
||||
title function name inside a header
|
||||
params everything in parentheses inside a function header
|
||||
preprocessor preprocessor directive
|
||||
|
||||
AVR assembler ("avrasm"):
|
||||
|
||||
keyword keyword
|
||||
built_in pre-defined register
|
||||
number number
|
||||
string string
|
||||
comment commment
|
||||
label label
|
||||
preprocessor preprocessor directive
|
||||
localvars substitution in .macro
|
||||
|
||||
Parser3 ("parser3"):
|
||||
|
||||
keyword keyword
|
||||
number number
|
||||
comment commment
|
||||
variable variable starting with "$"
|
||||
preprocessor preprocessor directive
|
||||
title user-defined name starting with "@"
|
||||
|
||||
TeX ("tex"):
|
||||
|
||||
comment comment
|
||||
number number
|
||||
command command
|
||||
parameter parameter
|
||||
formula formula
|
||||
special special symbol
|
||||
|
||||
|
||||
## Heuristics
|
||||
|
||||
Autodetection of a code's language is done with a simple heuristics:
|
||||
the program tries to highlight a fragment with all available languages and
|
||||
counts all syntactic structures that it finds along the way. The language
|
||||
with greatest count wins.
|
||||
|
||||
This means that in short fragments the probability of an error is high
|
||||
(and it really happens sometimes). In this cases you can set the fragment's
|
||||
language explicitly by assigning a class to the `<code>` element:
|
||||
|
||||
<pre><code class="html">...</code></pre>
|
||||
|
||||
You can use class names recommended in HTML5: "language-html",
|
||||
"language-php". Classes also can be assigned to the `<pre>` element.
|
||||
|
||||
To disable highlighting of a fragment altogether use "no-highlight" class:
|
||||
|
||||
<pre><code class="no-highlight">...</code></pre>
|
||||
|
||||
## Contacts
|
||||
|
||||
Version: 5.11
|
||||
URL: http://softwaremaniacs.org/soft/highlight/en/
|
||||
Author: Ivan Sagalaev (Maniac@SoftwareManiacs.Org)
|
||||
|
||||
For the license terms see LICENSE files.
|
||||
For the list of contributors see AUTHORS.en.txt file.
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
Description: Magula style for highligh.js
|
||||
Author: Ruslan Keba <rukeba@gmail.com>
|
||||
Website: http://rukeba.com/
|
||||
Version: 1.0
|
||||
Date: 2009-01-03
|
||||
Music: Aphex Twin / Xtal
|
||||
*/
|
||||
|
||||
|
||||
pre code, pre .ruby .subst, pre .lisp .title { color: black; }
|
||||
pre .string, pre .title, pre .parent, pre .tag .attribute .value, pre .rules .value, pre .rules .value .number, pre .preprocessor, pre .ruby .symbol, pre .ruby .symbol .string, pre .ruby .symbol .keyword, pre .ruby .symbol .keymethods, pre .instancevar, pre .aggregate, pre .template_tag, pre .django .variable, pre .smalltalk .class, pre .addition, pre .flow, pre .stream, pre .bash .variable, pre .apache .cbracket { color: #008200; }
|
||||
pre .comment, pre .annotation, pre .template_comment, pre .diff .header, pre .chunk { color: #777; }
|
||||
pre .number, pre .date, pre .regexp, pre .literal, pre .smalltalk .symbol, pre .smalltalk .char, pre .change, pre .tex .special { color: #B50000; }
|
||||
pre .label, pre .javadoc, pre .ruby .string, pre .decorator, pre .filter .argument, pre .localvars, pre .array, pre .attr_selector, pre .pseudo, pre .pi, pre .doctype, pre .deletion, pre .envvar, pre .shebang, pre .apache .sqbracket, pre .nginx .built_in, pre .tex .formula { color: #00e; }
|
||||
pre .keyword, pre .id, pre .phpdoc, pre .title, pre .built_in, pre .aggregate, pre .smalltalk .class, pre .winutils, pre .bash .variable, pre .apache .tag, pre .xml .tag, pre .xml .title, pre .tex .command { font-weight: bold; color: navy; }
|
||||
pre .nginx .built_in { font-weight: normal; }
|
||||
pre .html .css, pre .html .javascript, pre .html .vbscript, pre .tex .formula { opacity: 0.5; }
|
||||
/* --- */
|
||||
pre .apache .tag { font-weight: bold; color: blue; }
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user