File size: 497 Bytes
a1271b8
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* allow folding of complete cell, if IPython magic symbol "%" is in first line */
CodeMirror.registerHelper("fold", "magic", function(cm, start) {
  var mode = cm.getMode(), Token = "%%";
  if (start.line == 0) {
      var lineText = cm.getLine(start.line);
      var found = lineText.lastIndexOf(Token,0);
      if (found == 0) {
        end =  cm.lastLine();
        return {from: CodeMirror.Pos(start.line, null),
              to: CodeMirror.Pos(end, null)};
        }
    }
    return ;
});