css for javascript is not working. Does not highlight. See this print screen: https://snipboard.io/TNDxut.jpg
I connect those files from codemirror and I add <pre>
and </pre>
before and after java code lines. And it is not working.
Can anyone help me? What did I miss ? What can I do to work my code?
This is my code from print screen:
<html>
<head>
<meta charset="utf-8">
<title>Code Mirror</title>
<script src="c:/Users/Castel/Videos/Code Mirror/src/codemirror.js"></script>
<link rel="stylesheet" href="c:/Users/Castel/Videos/Code Mirror/lib/codemirror.css">
<script type="text/javascript" src="c:/Users/Castel/Videos/Code Mirror/mode/javascript/javascript.js"></script>
</head>
<body>
<p>Bebe este acasa</p>
<textarea id='demotext'>
function foo() {
for(i = 0, i < 10, i++)
console.log(i);
}
</textarea>
<pre>
<script type="text/javascript">
var editor = CodeMirror.fromTextArea(document.getElementById("demotext"), {
lineNumbers: true,
mode: "javascript"
});
// Demo for running a CodeMirror parser over a piece of code without
// creating an actual editor.
(function(){
function normaliseString(string) {
var tab = "";
for (var i = 0; i < indentUnit; i++) tab += " ";
string = string.replace(/\t/g, tab).replace(/\u00a0/g, " ").replace(/\r\n?/g, "\n");
var pos = 0, parts = [], lines = string.split("\n");
for (var line = 0; line < lines.length; line++) {
if (line != 0) parts.push("\n");
parts.push(lines[line]);
}
return {
next: function() {
if (pos < parts.length) return parts[pos++];
else throw StopIteration;
}
};
}
window.highlightText = function(string, output, parser) {
var parser = (parser || Editor.Parser).make(stringStream(normaliseString(string)));
try {
while (true) {
var token = parser.next();
var span = document.createElement("SPAN");
span.className = token.style;
span.appendChild(document.createTextNode(token.value));
output.appendChild(span);
}
}
catch (e) {
if (e != StopIteration) throw e;
}
}
})();
</script>
</pre>
<p>Oana este acasa</p>
</body>
</html>