fix static_highlight
This commit is contained in:
parent
ad9b656c14
commit
86100b5ebe
2 changed files with 11 additions and 16 deletions
|
|
@ -70,12 +70,12 @@ exports.render = function(input, mode, theme, lineStart, disableGutter) {
|
||||||
|
|
||||||
var stringBuilder = [];
|
var stringBuilder = [];
|
||||||
var length = session.getLength();
|
var length = session.getLength();
|
||||||
|
|
||||||
for(var ix = 0; ix < length; ix++) {
|
for(var ix = 0; ix < length; ix++) {
|
||||||
stringBuilder.push("<div class='ace_line'>");
|
stringBuilder.push("<div class='ace_line'>");
|
||||||
if (!disableGutter)
|
if (!disableGutter)
|
||||||
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
|
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
|
||||||
textLayer.$renderLine(stringBuilder, 0, true, false);
|
textLayer.$renderLine(stringBuilder, ix, true, false);
|
||||||
stringBuilder.push("</div>");
|
stringBuilder.push("</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ module.exports = {
|
||||||
|
|
||||||
"test simple snippet": function(next) {
|
"test simple snippet": function(next) {
|
||||||
var theme = require("../theme/tomorrow");
|
var theme = require("../theme/tomorrow");
|
||||||
var snippet = "/** this is a function\n\
|
var snippet = "\
|
||||||
|
/** this is a function\n\
|
||||||
*\n\
|
*\n\
|
||||||
*/\n\
|
*/\n\
|
||||||
function hello (a, b, c) {\n\
|
function hello (a, b, c) {\n\
|
||||||
|
|
@ -24,23 +25,16 @@ function hello (a, b, c) {\n\
|
||||||
}";
|
}";
|
||||||
var mode = new JavaScriptMode();
|
var mode = new JavaScriptMode();
|
||||||
|
|
||||||
var isError = false, result;
|
var result = highlighter.render(snippet, mode, theme);
|
||||||
try {
|
assert.equal(result.html, "<div class='ace-tomorrow'> <div class='ace_editor ace_scroller ace_text-layer'> <div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>1</span><span class='ace_comment ace_doc'>/** this is a function</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>2</span><span class='ace_comment ace_doc'>*</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>3</span><span class='ace_comment ace_doc'>*/</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>4</span><span class='ace_storage ace_type'>function</span> <span class='ace_entity ace_name ace_function'>hello</span> <span class='ace_paren ace_lparen'>(</span><span class='ace_variable ace_parameter'>a</span><span class='ace_punctuation ace_operator'>, </span><span class='ace_variable ace_parameter'>b</span><span class='ace_punctuation ace_operator'>, </span><span class='ace_variable ace_parameter'>c</span><span class='ace_paren ace_rparen'>)</span> <span class='ace_paren ace_lparen'>{</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>5</span>    <span class='ace_storage ace_type'>console</span><span class='ace_punctuation ace_operator'>.</span><span class='ace_support ace_function ace_firebug'>log</span><span class='ace_paren ace_lparen'>(</span><span class='ace_identifier'>a</span> <span class='ace_keyword ace_operator'>*</span> <span class='ace_identifier'>b</span> <span class='ace_keyword ace_operator'>+</span> <span class='ace_identifier'>c</span> <span class='ace_keyword ace_operator'>+</span> <span class='ace_string'>'sup?'</span><span class='ace_paren ace_rparen'>)</span><span class='ace_punctuation ace_operator'>;</span></div><div class='ace_line'><span class='ace_gutter ace_gutter-cell' unselectable='on'>6</span><span class='ace_paren ace_rparen'>}</span></div> </div> </div>");
|
||||||
result = highlighter.render(snippet, mode, theme);
|
assert.ok(!!result.css);
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
isError = true;
|
|
||||||
}
|
|
||||||
// todo: write something more meaningful
|
|
||||||
assert.equal(isError, false);
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
|
|
||||||
"test css from theme is used": function(next) {
|
"test css from theme is used": function(next) {
|
||||||
var theme = require("../theme/tomorrow");
|
var theme = require("../theme/tomorrow");
|
||||||
var snippet = "/** this is a function\n\
|
var snippet = "\
|
||||||
|
/** this is a function\n\
|
||||||
*\n\
|
*\n\
|
||||||
*/\n\
|
*/\n\
|
||||||
function hello (a, b, c) {\n\
|
function hello (a, b, c) {\n\
|
||||||
|
|
@ -58,7 +52,8 @@ function hello (a, b, c) {\n\
|
||||||
|
|
||||||
"test theme classname should be in output html": function (next) {
|
"test theme classname should be in output html": function (next) {
|
||||||
var theme = require("../theme/tomorrow");
|
var theme = require("../theme/tomorrow");
|
||||||
var snippet = "/** this is a function\n\
|
var snippet = "\
|
||||||
|
/** this is a function\n\
|
||||||
*\n\
|
*\n\
|
||||||
*/\n\
|
*/\n\
|
||||||
function hello (a, b, c) {\n\
|
function hello (a, b, c) {\n\
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue