http://fiddle.jshell.net/tLth8/6/show/
在 IE <9 中,代码被突出显示,但新行被忽略,代码都在一行中,如下所示
我怎样才能像下面的源代码一样正确渲染线条
我试过改变css所以行display:block;
但是没有区别
我试过的
.CodeMirror pre {
display:block;
}
.CodeMirror-lines div{
display:block;
}
jQuery 源代码:
$("span.code, div.code").each(function () {
var $this = $(this),
isdiv = $this.is("div"),
$code = (isdiv) ? $this.html().replace(/^(\r\n)|(\n)/, ''):$this.html(),
$unescaped = (isdiv) ? $('<div/>').html($code).text() : $('<span/>').html($code).text();
$this.empty();
if (isdiv) {
$this.css({
"display": "block"
});
$this.after('<div class="clear"/>');
}
var editor = CodeMirror(this, {
value: $unescaped,
mode: (isdiv) ? "text/html" : "javascript",
lineNumbers: (isdiv) ? true : false,
readOnly: false
});
if (isdiv) {
var linecount = editor.lineCount();
for (j = 0; j < linecount; j++) {
editor.indentLine(j);
}
}
});