-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dist] Vendored highlight.js library
- Loading branch information
Showing
44 changed files
with
6,699 additions
and
3 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
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
File renamed without changes.
File renamed without changes.
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,129 @@ | ||
/* | ||
github.com style (c) Vasily Polovnyov <[email protected]> | ||
*/ | ||
|
||
pre code { | ||
display: block; padding: 0.5em; | ||
color: #000; | ||
background: #f8f8ff | ||
} | ||
|
||
pre .comment, | ||
pre .template_comment, | ||
pre .diff .header, | ||
pre .javadoc { | ||
color: #998; | ||
font-style: italic | ||
} | ||
|
||
pre .keyword, | ||
pre .css .rule .keyword, | ||
pre .winutils, | ||
pre .javascript .title, | ||
pre .lisp .title, | ||
pre .subst { | ||
color: #000; | ||
font-weight: bold | ||
} | ||
|
||
pre .number, | ||
pre .hexcolor { | ||
color: #40a070 | ||
} | ||
|
||
pre .string, | ||
pre .tag .value, | ||
pre .phpdoc, | ||
pre .tex .formula { | ||
color: #d14 | ||
} | ||
|
||
pre .title, | ||
pre .id { | ||
color: #900; | ||
font-weight: bold | ||
} | ||
|
||
pre .javascript .title, | ||
pre .lisp .title, | ||
pre .subst { | ||
font-weight: normal | ||
} | ||
|
||
pre .class .title, | ||
pre .haskell .label, | ||
pre .tex .command { | ||
color: #458; | ||
font-weight: bold | ||
} | ||
|
||
pre .tag, | ||
pre .tag .title, | ||
pre .rules .property, | ||
pre .django .tag .keyword { | ||
color: #000080; | ||
font-weight: normal | ||
} | ||
|
||
pre .attribute, | ||
pre .variable, | ||
pre .instancevar, | ||
pre .lisp .body { | ||
color: #008080 | ||
} | ||
|
||
pre .regexp { | ||
color: #009926 | ||
} | ||
|
||
pre .class { | ||
color: #458; | ||
font-weight: bold | ||
} | ||
|
||
pre .symbol, | ||
pre .ruby .symbol .string, | ||
pre .ruby .symbol .keyword, | ||
pre .ruby .symbol .keymethods, | ||
pre .lisp .keyword, | ||
pre .tex .special, | ||
pre .input_number { | ||
color: #990073 | ||
} | ||
|
||
pre .builtin, | ||
pre .built_in, | ||
pre .lisp .title { | ||
color: #0086b3 | ||
} | ||
|
||
pre .preprocessor, | ||
pre .pi, | ||
pre .doctype, | ||
pre .shebang, | ||
pre .cdata { | ||
color: #999; | ||
font-weight: bold | ||
} | ||
|
||
pre .deletion { | ||
background: #fdd | ||
} | ||
|
||
pre .addition { | ||
background: #dfd | ||
} | ||
|
||
pre .diff .change { | ||
background: #0086b3 | ||
} | ||
|
||
pre .chunk { | ||
color: #aaa | ||
} | ||
|
||
pre .tex .formula { | ||
opacity: 0.5; | ||
} |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Copyright (c) 2010, Andris Reinman | ||
<http://www.andrisreinman.com/> | ||
All rights reserved. | ||
|
||
Original Highlight.js 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. |
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,37 @@ | ||
highlight | ||
============== | ||
|
||
**highlight** for node.js is based on [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) parser and is meant to highlight code syntax in languages that are not known beforehand (*highlight.js* detects the used language automatically). This is especially important for pages in Markdown format - there's no easy way to know which language is actually used. | ||
|
||
Installation | ||
------------ | ||
|
||
Use `npm` package manager | ||
|
||
npm install highlight | ||
|
||
Usage | ||
----- | ||
|
||
Include syntax highlighter | ||
|
||
var hl = require("highlight").Highlight; | ||
|
||
highlight code | ||
|
||
html = hl("for(var i=0;i<10;i++)alert(i);"); | ||
|
||
use special tab replacing string (default is 4 spaces) | ||
|
||
html = hl(code_string, "<span> </span>"); | ||
|
||
convert code only between <code> blocks (leaves everything else as is) - especially useful if used together with converted [Markdown](/andris9/node-markdown) syntax that includes <code> blocks. | ||
|
||
html = hl("<p>PHP:</p><code><?php echo 'Hello world!';?></code>", false, true); | ||
|
||
Styles | ||
------ | ||
|
||
**highlight** outputs HTML code with predefined CSS class names for different elements. This doesn't make a lot of sense by default (it's just a bunch of SPAN's) so you need to use a CSS file that sets the used color set for the highlighting. There's some sample CSS files in /lib/vendor/highlight.js/styles that can be used with no modification - just include one of the files in the page you are showing the highlighted code. | ||
|
||
<link rel="stylesheet" href="/path/to/styles/default.css"/> |
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,25 @@ | ||
|
||
|
||
var hl = require("../lib/highlight.js").Highlight, | ||
code_string = "<?php\n"+ | ||
"\techo \"Hello world!\";\n"+ | ||
"\tfor($i=0;$i<100;$i++){\n"+ | ||
"\t\techo \"$i\";\n"+ | ||
"\t}\n"+ | ||
"?>", | ||
|
||
code_block = "<p>PHP code:</p>\n"+ | ||
"<code><?php\n"+ | ||
"\techo \"Hello world!\";\n"+ | ||
"\tfor($i=0;$i<100;$i++){\n"+ | ||
"\t\techo \"$i\";\n"+ | ||
"\t}\n"+ | ||
"?></code>", | ||
|
||
html1 = hl(code_string), // convert all | ||
html2 = hl(code_string,' '), // convert with special tab replacer | ||
html3 = hl(code_block, false, true); // convert only inside <code/> | ||
|
||
console.log(html1); | ||
console.log(html2); | ||
console.log(html3); |
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,33 @@ | ||
/* node-highlight is based on highlight.js (see vendor/highlight.js) */ | ||
/* usage: html = require("highlight").Highlight(code_string); */ | ||
/* NB! You also need to include a CSS file from vendor/highlight.js/styles */ | ||
|
||
// load syntax highlighter | ||
var hljs = require("./vendor/highlight.js/highlight").hljs; | ||
|
||
// load langs | ||
require("./vendor/highlight.js/languages/bash")(hljs); | ||
require("./vendor/highlight.js/languages/javascript")(hljs); | ||
require("./vendor/highlight.js/languages/ruby")(hljs); | ||
|
||
|
||
|
||
/** | ||
* highlight(text, tabReplace, useCodeBlocks) -> HTML | ||
* - text (String): text to be highlighted | ||
* - tabReplace (String): defaults to 4 spaces if none, replaces \t chars | ||
* - useCodeBlocks (Boolean): If TRUE use only text between <code> and </code> | ||
* | ||
* Highlights program code inside a string by setting appropriate CSS class | ||
* elements. | ||
**/ | ||
this.Highlight = function(text, tabReplace, useCodeBlocks){ | ||
tabReplace = tabReplace || ' '; | ||
if(!!useCodeBlocks){ | ||
// JS regexpes have some multiline issues, so we temporarily remove them | ||
return text.replace(/\n/g,'\uffff').replace(/<code>(.*?)<\/code>/gm, function(original, source){ | ||
return '<code>'+hljs.highlightText(source.replace(/\uffff/g,"\n"), tabReplace)+'</code>'; | ||
}).replace(/&(\w+;)/g,'&$1').replace(/\uffff/g,"\n"); | ||
}else | ||
return hljs.highlightText(text, tabReplace); | ||
} |
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,45 @@ | ||
Syntax highlighting with language autodetection. | ||
|
||
URL: http://softwaremaniacs.org/soft/highlight/en/ | ||
|
||
Original author and current maintainer: | ||
Ivan Sagalaev <[email protected]> | ||
|
||
Contributors: | ||
|
||
- Peter Leonov <[email protected]> | ||
- Victor Karamzin <[email protected]> | ||
- Vsevolod Solovyov <[email protected]> | ||
- Anton Kovalyov <[email protected]> | ||
- Nikita Ledyaev <[email protected]> | ||
- Konstantin Evdokimenko <[email protected]> | ||
- Dmitri Roudakov <[email protected]> | ||
- Yuri Ivanov <[email protected]> | ||
- Vladimir Ermakov <[email protected]> | ||
- Vladimir Gubarkov <[email protected]> | ||
- Brian Beck <[email protected]> | ||
- MajestiC <[email protected]> | ||
- Vasily Polovnyov <[email protected]> | ||
- Vladimir Epifanov <[email protected]> | ||
- Alexander Makarov (http://rmcreative.ru/) | ||
- Vah <[email protected]> | ||
- Shuen-Huei Guan <[email protected]> | ||
- Jason Diamond <[email protected]> | ||
- Michal Gabrukiewicz <[email protected]> | ||
- Ruslan Keba <[email protected]> | ||
- Sergey Baranov <[email protected]> | ||
- Zaripov Yura <[email protected]> | ||
- Oleg Volchkov <[email protected]> | ||
- Vasily Mikhailitchenko <[email protected]> | ||
- Jan Berkel <[email protected]> | ||
- Vladimir Moskva <[email protected]> | ||
- Loren Segal <[email protected]> | ||
- Andrew Fedorov <[email protected]> | ||
- Igor Kalnitsky <[email protected]> | ||
- Jeremy Hull <[email protected]> | ||
- Valerii Hiora <[email protected]> | ||
- Nikolay Zakharov <[email protected]> | ||
- Dmitry Kovega <[email protected]> | ||
- Sergey Ignatov <[email protected]> | ||
- Antono Vasiljev <[email protected]> | ||
- Stephan Kountso <[email protected]> |
Oops, something went wrong.