fix #1492 $' breaks static-highligher
This commit is contained in:
parent
81f7dd7fbb
commit
8068b01f21
3 changed files with 26 additions and 12 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
* Simple node.js server, which generates the synax highlighted version of itself
|
* 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.
|
* using the Ace modes and themes on the server and serving a static web page.
|
||||||
*/
|
*/
|
||||||
|
// $'
|
||||||
// include ace search path and modules
|
// include ace search path and modules
|
||||||
require("amd-loader");
|
require("amd-loader");
|
||||||
|
|
||||||
|
|
@ -23,12 +23,14 @@ http.createServer(function(req, res) {
|
||||||
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
|
res.writeHead(200, {"Content-Type": "text/html; charset=utf-8"});
|
||||||
fs.readFile(__filename, "utf8", function(err, data) {
|
fs.readFile(__filename, "utf8", function(err, data) {
|
||||||
var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
|
var highlighted = highlighter.render(data, new JavaScriptMode(), theme);
|
||||||
res.end('<html><body>\n\
|
res.end(
|
||||||
<style type="text/css" media="screen">\n\
|
'<html><body>\n' +
|
||||||
:css:\n\
|
'<style type="text/css" media="screen">\n' +
|
||||||
</style>\n\
|
highlighted.css +
|
||||||
:html:\n\
|
'</style>\n' +
|
||||||
</body></html>'.replace(":css:", highlighted.css).replace(":html:", highlighted.html));
|
highlighted.html +
|
||||||
|
'</body></html>'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}).listen(port);
|
}).listen(port);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,11 +120,11 @@ exports.renderSync = function(input, mode, theme, lineStart, disableGutter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// let's prepare the whole html
|
// let's prepare the whole html
|
||||||
var html = "<div class=':cssClass'>\
|
var html = "<div class='" + theme.cssClass + "'>" +
|
||||||
<div class='ace_editor ace_scroller ace_text-layer'>\
|
"<div class='ace_editor ace_scroller ace_text-layer'>" +
|
||||||
:code\
|
stringBuilder.join("") +
|
||||||
</div>\
|
"</div>" +
|
||||||
</div>".replace(/:cssClass/, theme.cssClass).replace(/:code/, stringBuilder.join(""));
|
"</div>";
|
||||||
|
|
||||||
textLayer.destroy();
|
textLayer.destroy();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ define(function(require, exports, module) {
|
||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
var highlighter = require("./static_highlight");
|
var highlighter = require("./static_highlight");
|
||||||
var JavaScriptMode = require("../mode/javascript").Mode;
|
var JavaScriptMode = require("../mode/javascript").Mode;
|
||||||
|
var TextMode = require("../mode/text").Mode;
|
||||||
|
|
||||||
// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite
|
// Execution ORDER: test.setUpSuite, setUp, testFn, tearDown, test.tearDownSuite
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
@ -65,6 +66,17 @@ function hello (a, b, c) {\n\
|
||||||
result = highlighter.render(snippet, mode, theme);
|
result = highlighter.render(snippet, mode, theme);
|
||||||
assert.equal(!!result.html.match(/<div class='ace-tomorrow'>/), true);
|
assert.equal(!!result.html.match(/<div class='ace-tomorrow'>/), true);
|
||||||
|
|
||||||
|
next();
|
||||||
|
},
|
||||||
|
|
||||||
|
"test js string replace specials": function(next) {
|
||||||
|
var theme = require("../theme/tomorrow");
|
||||||
|
var snippet = "$'$&$1$2$$";
|
||||||
|
var mode = new TextMode();
|
||||||
|
|
||||||
|
result = highlighter.render(snippet, mode, theme);
|
||||||
|
assert.ok(result.html.indexOf(snippet) != -1);
|
||||||
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue