in IE <9 the code is highlighted however new lines are ignored and the code is all on a single line like below
how can i get the lines to be rendered properly as in the source code like below
I have tried altering the css so lines are display:block;
however there is no difference
what i have tried
.CodeMirror pre {
display:block;
}
.CodeMirror-lines div{
display:block;
}
$("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);
}
}
});
I've always used a textarea tag to initialise codemirror. It's how it's done on the main site.
Just tested it and it Works in ie8, ie9.
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: 'htmlmixed',
tabMode: "indent"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With