Code to copy codemirror on one line

http://fiddle.jshell.net/tLth8/6/show/

in IE <9, code is highlighted, but newlines are ignored, and code is on the same line, as shown below How the code is rendered in ie <9

how can I get strings that will display correctly, as in the source code, as shown below

How the code should be rendered, (google chrome)

I tried changing css so that the lines were display:block; but no difference

what i tried

 .CodeMirror pre { display:block; } .CodeMirror-lines div{ display:block; } 

JQuery source:

 $("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); } } }); 
+4
source share
1 answer

I always used the textarea tag to initialize codemirror. How to do it on the main site.

Just tested it and it works in ie8, ie9.

 var editor = CodeMirror.fromTextArea(document.getElementById("code"), { mode: 'htmlmixed', tabMode: "indent" }); 
+1
source

All Articles