diff --git a/src/static/node_modules/highlight/LICENSE b/src/static/node_modules/highlight/LICENSE new file mode 100644 index 0000000..ba42317 --- /dev/null +++ b/src/static/node_modules/highlight/LICENSE @@ -0,0 +1,29 @@ +Copyright (c) 2010, Andris Reinman + +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. diff --git a/src/static/node_modules/highlight/README.md b/src/static/node_modules/highlight/README.md new file mode 100644 index 0000000..96e7283 --- /dev/null +++ b/src/static/node_modules/highlight/README.md @@ -0,0 +1,44 @@ +DEPRECATION NOTICE +================== + +This project is deprecated in favor of [isagalaev/highlight.js](https://github.com/isagalaev/highlight.js). I never created the parser myself, the module was created in the early days of node as a wrapper for an existing browser based parser [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) so if you are using this module and have problems with the parsing logic, I can't help you much as I'm not familiar with the inner details. + +Pull requests are still welcomed - if you find a bug and fix it, then I'll pull the change in but I won't be fixing the bugs myself. Sorry for that. + +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, " "); + +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("

PHP:

", 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. + + diff --git a/src/static/node_modules/highlight/bin/highlight-cli.js b/src/static/node_modules/highlight/bin/highlight-cli.js new file mode 100644 index 0000000..a1dc1df --- /dev/null +++ b/src/static/node_modules/highlight/bin/highlight-cli.js @@ -0,0 +1,113 @@ +#!/usr/bin/env node +(function () { + "use strict"; + + var fs = require('fs') + , Highlight = require('highlight') + //, Highlight = require('../lib/highlight') + , filename = process.argv[2] + , langArgIndex = 4 + , langArg + , langs + ; + + if (filename.match(/--languages(=)?/)) { + langArg = filename; + langArgIndex = 3; + filename = null; + } + + langArg = process.argv[langArgIndex - 1] || ''; + + if (langArg = langArg.match(/--languages(=(.*))?/)) { + langs = (process.argv[langArgIndex]||'').split(/\s*,\s*/g); + + if (langArg[2]) { + langs = langArg[2].split(/,/); + } + } + + function printUsage() { + console.warn("Usages:"); + console.warn("highlight site/docs/index.html > highlighted.html"); + console.warn("cat site/docs/index.html | highlight > highlighted.html"); + } + + function handleInput(err, text) { + var hlBlock + , wrappedInHtml + ; + + if (err) { + printUsage(); + return; + } + + wrappedInHtml = !!text.match(/<.*?code.*?>/i); + + // TODO test if filename extension reveals code type + Highlight.init(function (err) { + if (err) { + console.error('[highlight-cli]', err.message); + //console.error(err.stack); + return; + } + + hlBlock = Highlight.highlight(text, ' ', wrappedInHtml); + console.info(hlBlock); + }, langs); + } + + readInput(handleInput, filename); + + // + // this could (and probably should) be its own module + // + function readInput(cb, filename) { + + function readFile() { + fs.readFile(filename, 'utf8', function (err, text) { + if (err) { + console.error("[ERROR] couldn't read from '" + filename + "':"); + console.error(err.message); + return; + } + + cb(err, text); + }); + } + + function readStdin() { + var text = '' + , timeoutToken + , stdin = process.stdin + ; + + stdin.resume(); + + // how to tell piping vs waiting for user input? + timeoutToken = setTimeout(function () { + cb(new Error('no stdin data')); + stdin.pause(); + }, 1000); + + stdin.on('data', function (chunk) { + clearTimeout(timeoutToken); + text += chunk; + }); + + stdin.on('end', function () { + cb(null, text); + }); + } + + if (filename) { + readFile(); + } + else { + readStdin(); + } + + } + +}()); diff --git a/src/static/node_modules/highlight/bin/package.json b/src/static/node_modules/highlight/bin/package.json new file mode 100644 index 0000000..afcf342 --- /dev/null +++ b/src/static/node_modules/highlight/bin/package.json @@ -0,0 +1,34 @@ +{ + "name" : "highlight-cli", + "description" : "cli for the highlight module", + "version" : "1.1.0", + "author" : "AJ ONeal", + "homepage": "https://github.com/andris9/highlight", + "maintainers":[ + { + "name":"andris", + "email":"andris@node.ee" + } + ], + "engines": { + "node": "*" + }, + "repository" : { + "type" : "git", + "url" : "http://github.com/andris9/highlight.git" + }, + "bin": { + "highlight": "./highlight-cli.js" + }, + "main": "./highlight-cli", + "dependencies": { + "highlight": "*" + }, + "licenses" : [ + { + "type": "BSD", + "url": "http://github.com/andris9/highlight/blob/master/LICENSE" + } + ], + "preferGlobal": true +} diff --git a/src/static/node_modules/highlight/examples/example.html b/src/static/node_modules/highlight/examples/example.html new file mode 100644 index 0000000..810e1e3 --- /dev/null +++ b/src/static/node_modules/highlight/examples/example.html @@ -0,0 +1,16 @@ + + + + Foo + + + Bar +
+ Baz +

Quux

+ + + diff --git a/src/static/node_modules/highlight/examples/example.js b/src/static/node_modules/highlight/examples/example.js new file mode 100644 index 0000000..f2799c2 --- /dev/null +++ b/src/static/node_modules/highlight/examples/example.js @@ -0,0 +1,5 @@ +(function () { + "use strict"; + + console.log('Hello World!'); +}(); diff --git a/src/static/node_modules/highlight/examples/example.js.html b/src/static/node_modules/highlight/examples/example.js.html new file mode 100644 index 0000000..a7a6034 --- /dev/null +++ b/src/static/node_modules/highlight/examples/example.js.html @@ -0,0 +1,5 @@ +
(function () {
+  "use strict";
+
+  console.log('Hello World!');
+}();
diff --git a/src/static/node_modules/highlight/examples/should-annotate-xml.js b/src/static/node_modules/highlight/examples/should-annotate-xml.js new file mode 100644 index 0000000..75b0812 --- /dev/null +++ b/src/static/node_modules/highlight/examples/should-annotate-xml.js @@ -0,0 +1,29 @@ +(function () { + "use strict"; + + var Highlight = require("../lib/highlight.js") + , assert = require('assert') + , fs = require('fs') + , reHasAnnotations = /\sclass="tag"/ + ; + + function runTest(err) { + + assert.ok(!err, err && err.message); + assert.strictEqual(1, Highlight.loadedLanguages.length, 'more than one language is loaded: ' + Highlight.loadedLanguages); + assert.strictEqual('xml', Highlight.loadedLanguages[0], 'xml isn\'t the language'); + + fs.readFile('./example.html', 'utf8', function (err, text) { + var annotated + ; + + assert.ok(!err, 'threw error reading example.html'); + annotated = Highlight.highlight(text, ' '); + assert.ok(annotated.match(reHasAnnotations)); + //console.log(annotated); + console.info('[PASS] source is annotated'); + }); + } + + Highlight.init(runTest, ['xml']); +}()); diff --git a/src/static/node_modules/highlight/examples/should-load-all-languages.js b/src/static/node_modules/highlight/examples/should-load-all-languages.js new file mode 100644 index 0000000..cd26661 --- /dev/null +++ b/src/static/node_modules/highlight/examples/should-load-all-languages.js @@ -0,0 +1,41 @@ +(function () { + "use strict"; + + var Highlight = require("../lib/highlight.js") + , assert = require('assert') + , fs = require('fs') + , reHasAnnotations = /\sclass="[\w-]+"/ + ; + + function runTest(err) { + + //console.log(Highlight.loadedLanguages); + assert.ok(!err, err && err.message); + assert.strictEqual(Highlight.languages.length, Highlight.loadedLanguages.length + , 'not all languages were loaded: ' + + Highlight.languages.length + + " " + + Highlight.loadedLanguages.length + ); + assert.deepEqual(Highlight.languages, Highlight.loadedLanguages + , 'not all languages were loaded: ' + + JSON.stringify(Highlight.languages, null, ' ') + + "\n" + + JSON.stringify(Highlight.loadedLanguages, null, ' ') + ); + + // It's okay that these run out-of-order / in-parallel + fs.readFile('./example.js', 'utf8', function (err, text) { + var annotated + ; + + assert.ok(!err, 'threw error reading example.js'); + annotated = Highlight.highlight(text, ' '); + assert.ok(annotated.match(reHasAnnotations)); + //console.log(annotated); + console.info('[PASS] annotated source (perhaps incorrectly) with all modules loaded'); + }); + } + + Highlight.init(runTest); +}()); diff --git a/src/static/node_modules/highlight/examples/should-load-js-only.js b/src/static/node_modules/highlight/examples/should-load-js-only.js new file mode 100644 index 0000000..4a5fed8 --- /dev/null +++ b/src/static/node_modules/highlight/examples/should-load-js-only.js @@ -0,0 +1,29 @@ +(function () { + "use strict"; + + var Highlight = require("../lib/highlight.js") + , assert = require('assert') + , fs = require('fs') + , reHasAnnotations = /\sclass="[\w-]+"/ + ; + + function runTest(err) { + + assert.ok(!err, err && err.message); + assert.strictEqual(1, Highlight.loadedLanguages.length, 'more than one language is loaded: ' + Highlight.loadedLanguages); + assert.strictEqual('javascript', Highlight.loadedLanguages[0], 'javascript is the language'); + + fs.readFile('./example.js.html', 'utf8', function (err, text) { + var annotated + ; + + assert.ok(!err, 'threw error reading example.js.html'); + annotated = Highlight.highlight(text, ' ', true); + assert.ok(annotated.match(reHasAnnotations)); + //console.log(annotated); + console.info('[PASS] source is annotated'); + }); + } + + Highlight.init(runTest, ['javascript']); +}()); diff --git a/src/static/node_modules/highlight/examples/should-load-no-languages.js b/src/static/node_modules/highlight/examples/should-load-no-languages.js new file mode 100644 index 0000000..2cfe31a --- /dev/null +++ b/src/static/node_modules/highlight/examples/should-load-no-languages.js @@ -0,0 +1,36 @@ +(function () { + "use strict"; + + var Highlight = require("../lib/highlight.js") + , assert = require('assert') + , fs = require('fs') + , reHasMarkup = /<.*class=["']?[\w-]+["'?]/ + , reHasAnnotations = /\sclass="[\w-]+"/ + ; + + function runTest(err) { + + //console.log(Highlight.loadedLanguages); + assert.ok(!err, err && err.message); + assert.strictEqual(0, Highlight.loadedLanguages.length + , 'some languages were loaded: ' + + Highlight.languages.length + + " " + + Highlight.loadedLanguages.length + ); + + // It's okay that these run out-of-order / in-parallel + fs.readFile('./example.js', 'utf8', function (err, text) { + var annotated + ; + + assert.ok(!err, 'threw error reading example.js'); + annotated = Highlight.highlight(text, ' '); + assert.ok(!annotated.match(reHasAnnotations)); + //console.log(annotated); + console.info('[PASS] source is not annotated'); + }); + } + + Highlight.init(runTest, []); +}()); diff --git a/src/static/node_modules/highlight/examples/test.js b/src/static/node_modules/highlight/examples/test.js new file mode 100644 index 0000000..1641b92 --- /dev/null +++ b/src/static/node_modules/highlight/examples/test.js @@ -0,0 +1,25 @@ + + +var hl = require("../lib/highlight.js").Highlight, + code_string = "", + + code_block = "

PHP code:

\n"+ + "", + + html1 = hl(code_string), // convert all + html2 = hl(code_string,' '), // convert with special tab replacer + html3 = hl(code_block, false, true); // convert only inside + +console.log(html1); +console.log(html2); +console.log(html3); \ No newline at end of file diff --git a/src/static/node_modules/highlight/package.json b/src/static/node_modules/highlight/package.json new file mode 100644 index 0000000..e33f258 --- /dev/null +++ b/src/static/node_modules/highlight/package.json @@ -0,0 +1,89 @@ +{ + "_args": [ + [ + { + "raw": "highlight", + "scope": null, + "escapedName": "highlight", + "name": "highlight", + "rawSpec": "", + "spec": "latest", + "type": "tag" + }, + "C:\\Box Sync\\pyDataVizDay\\src\\static" + ] + ], + "_from": "highlight@latest", + "_id": "highlight@0.2.4", + "_inCache": true, + "_location": "/highlight", + "_nodeVersion": "0.12.7", + "_npmUser": { + "name": "andris", + "email": "andris@kreata.ee" + }, + "_npmVersion": "2.11.3", + "_phantomChildren": {}, + "_requested": { + "raw": "highlight", + "scope": null, + "escapedName": "highlight", + "name": "highlight", + "rawSpec": "", + "spec": "latest", + "type": "tag" + }, + "_requiredBy": [ + "#USER" + ], + "_resolved": "https://registry.npmjs.org/highlight/-/highlight-0.2.4.tgz", + "_shasum": "8ac02875b03f5935e0675852b76cfe1fd58e0dff", + "_shrinkwrap": null, + "_spec": "highlight", + "_where": "C:\\Box Sync\\pyDataVizDay\\src\\static", + "author": { + "name": "Andris Reinman" + }, + "bugs": { + "url": "https://github.com/andris9/highlight/issues" + }, + "dependencies": {}, + "deprecated": "Not maintained anymore", + "description": "Highlight code syntax with node.js", + "devDependencies": {}, + "directories": { + "lib": "./lib" + }, + "dist": { + "shasum": "8ac02875b03f5935e0675852b76cfe1fd58e0dff", + "tarball": "https://registry.npmjs.org/highlight/-/highlight-0.2.4.tgz" + }, + "gitHead": "a955fd043e73a5d304e0987515641f1075bb88b2", + "homepage": "https://github.com/andris9/highlight#readme", + "licenses": [ + { + "type": "BSD", + "url": "http://github.com/andris9/highlight/blob/master/LICENSE" + } + ], + "main": "./lib/highlight", + "maintainers": [ + { + "name": "andris", + "email": "andris@node.ee" + }, + { + "name": "guileen", + "email": "guileen@gmail.com" + } + ], + "name": "highlight", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/andris9/highlight.git" + }, + "scripts": {}, + "version": "0.2.4" +}