Maybe it's just my relative inexperience with JavaScript but I struggled a bit to get a simple example of CodeMirror to work. The examples in the documentation and the download are all partial snippets and it wasn't obvious how to use them. In hopes of saving someone else some time, here's what I came up with. (Of course, it is trivial in retrospect!)
I was originally going to share a JSFiddle, but it does so much of the boilerplate for you, that it defeats the purpose! But you can run it there.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="http://codemirror.net/lib/codemirror.js"></script> | |
<link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css"> | |
<script type="text/javascript"> | |
window.onload = function () { | |
CodeMirror(document.body); | |
}; | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
No comments:
Post a Comment