Created
November 27, 2013 11:29
-
-
Save juhasch/7674242 to your computer and use it in GitHub Desktop.
Testcase for Python code folding using CodeMirror
This file contains hidden or 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> | |
<title>CodeMirror: Code Folding Demo</title> | |
<meta charset="utf-8"/> | |
<link rel=stylesheet href="../doc/docs.css"> | |
<link rel="stylesheet" href="../lib/codemirror.css"> | |
<link rel="stylesheet" href="../addon/fold/foldgutter.css" /> | |
<script src="../lib/codemirror.js"></script> | |
<script src="../addon/fold/foldcode.js"></script> | |
<script src="../addon/fold/foldgutter.js"></script> | |
<script src="../addon/fold/brace-fold.js"></script> | |
<script src="../addon/fold/indent-fold.js"></script> | |
<script src="../addon/fold/xml-fold.js"></script> | |
<script src="../addon/fold/comment-fold.js"></script> | |
<script src="../mode/python/python.js"></script> | |
<script src="../mode/xml/xml.js"></script> | |
<style type="text/css"> | |
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} | |
</style> | |
<div id=nav> | |
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a> | |
<ul> | |
<li><a href="../index.html">Home</a> | |
<li><a href="../doc/manual.html">Manual</a> | |
<li><a href="https://github.com/marijnh/codemirror">Code</a> | |
</ul> | |
<ul> | |
<li><a class=active href="#">Code Folding</a> | |
</ul> | |
</div> | |
<article> | |
<h2>Code Folding Demo</h2> | |
<form> | |
<div style="max-width: 50em; margin-bottom: 1em">Python:<br><textarea id="code" name="code"></textarea></div> | |
</form> | |
<script id="script"> | |
/* | |
* Demonstration of code folding | |
*/ | |
window.onload = function() { | |
var te = document.getElementById("code"); | |
te.value = '\ | |
# This is a header comment\n\ | |
\n\ | |
""" This\n\ | |
is\n\ | |
a\n\ | |
multiline comment\n\ | |
"""\n\ | |
'; | |
window.editor = CodeMirror.fromTextArea(te, { | |
mode: "python", | |
lineNumbers: true, | |
lineWrapping: true, | |
extraKeys: {"Ctrl-Q": function(cm){ cm.foldCode(cm.getCursor()); }}, | |
foldGutter: { | |
rangeFinder: new CodeMirror.fold.combine(CodeMirror.fold.indent, CodeMirror.fold.comment) | |
}, | |
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"] | |
}); | |
editor.foldCode(CodeMirror.Pos(8, 0)); | |
}; | |
</script> | |
</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment