mirror of
https://github.com/wassname/jupyter_contrib_nbextensions.git
synced 2026-08-10 12:20:38 +08:00
remove six requirement
* use explicit unicode string, which is supported in python 2 and in python 3.3+ (notebook requires at least 3.3, so we can assume this if py3 is in use at all) * use splitlines, rather than StringIO.readlines
This commit is contained in:
@@ -5,19 +5,17 @@ by the codefolding extension
|
||||
"""
|
||||
|
||||
from nbconvert.preprocessors import Preprocessor
|
||||
from six import StringIO, unichr
|
||||
|
||||
|
||||
class CodeFoldingPreprocessor(Preprocessor):
|
||||
|
||||
fold_mark = unichr(8596)
|
||||
fold_mark = u'↔'
|
||||
|
||||
def fold_cell(self, cell, folded):
|
||||
"""
|
||||
Remove folded lines and add a '<->' at the parent line
|
||||
"""
|
||||
f = StringIO(cell)
|
||||
lines = f.readlines()
|
||||
lines = cell.splitlines(True)
|
||||
|
||||
if folded[0] == 0 and (lines[0][0] == '#' or lines[0][0] == '%') :
|
||||
# fold whole cell when first line is a comment or magic
|
||||
|
||||
Reference in New Issue
Block a user