diff --git a/demo/static-highlighter/client.html b/demo/static-highlighter/client.html new file mode 100644 index 00000000..561add80 --- /dev/null +++ b/demo/static-highlighter/client.html @@ -0,0 +1,48 @@ + + + +
+ +Syntax highlighting using Ace language modes and themes.
+ + + + + + + + diff --git a/demo/static-highlighter/server.js b/demo/static-highlighter/server.js new file mode 100644 index 00000000..a58b00b6 --- /dev/null +++ b/demo/static-highlighter/server.js @@ -0,0 +1,36 @@ +/** + * Simple node.js server, which generates the synax highlighted version of itself + * using the Ace modes and themes on the server and serving a static web page. + */ + +// include ace search path and modules +require("../../support/paths"); + +// load jsdom, which is required by Ace +require("ace/test/mockdom"); + +var http = require("http"); +var fs = require("fs"); + +// load the highlighter and the desired mode and theme +var highlighter = require("ace/ext/static_highlight"); +var JavaScriptMode = require("ace/mode/javascript").Mode; +var theme = require("ace/theme/twilight"); + +var port = process.env.PORT || 2222; + +http.createServer(function(req, res) { + res.writeHead(200, {"Content-Type": "text/html"}); + + fs.readFile(__filename, "utf8", function(err, data) { + var highlighted = highlighter.render(data, new JavaScriptMode(), theme); + res.end('\n\ +\n\ +:html:\n\ +'.replace(":css:", highlighted.css).replace(":html:", highlighted.html)); + }); +}).listen(port); + +console.log("Listening on port " + port); \ No newline at end of file diff --git a/lib/ace/ext/static.css b/lib/ace/ext/static.css new file mode 100644 index 00000000..c2842bf4 --- /dev/null +++ b/lib/ace/ext/static.css @@ -0,0 +1,19 @@ +.ace_editor { + font-family: 'Monaco', 'Menlo', 'Droid Sans Mono', 'Courier New', monospace; + font-size: 12px; +} + +.ace_editor .ace_gutter { + width: 20px; + display: inline-block; + text-align: right; + padding: 0 3px 0 0; + margin-right: 3px; +} + +*.ace_gutter-cell { + -moz-user-select: -moz-none; + -khtml-user-select: none; + -webkit-user-select: none; + user-select: none; +} \ No newline at end of file diff --git a/lib/ace/ext/static_highlight.js b/lib/ace/ext/static_highlight.js new file mode 100644 index 00000000..cec33bf4 --- /dev/null +++ b/lib/ace/ext/static_highlight.js @@ -0,0 +1,94 @@ +/* vim:ts=4:sts=4:sw=4: + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Ajax.org Code Editor (ACE). + * + * The Initial Developer of the Original Code is + * Ajax.org B.V. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Jan Jongboom