Skip to content

Fix codefolding preprocessor configuration#1058

Merged
jcb91 merged 4 commits intoipython-contrib:masterfrom
juhasch:fix/cf_preprocessor
Aug 23, 2017
Merged

Fix codefolding preprocessor configuration#1058
jcb91 merged 4 commits intoipython-contrib:masterfrom
juhasch:fix/cf_preprocessor

Conversation

@juhasch
Copy link
Copy Markdown
Member

@juhasch juhasch commented Aug 22, 2017

Adresses #1047:

Adds configurable traitlets CodeFoldingPreprocessor.remove_folded_codeand
CodeFoldingPreprocessor.fold_mark.

@jfbercher
Copy link
Copy Markdown
Member

Perhaps adding a preprocess method would prevent calling preprocess_cell for each cell.

def preprocess(self, nb, resources):

        if self.remove_folded_code: 
            return super(CodeFoldingPreprocessor, self).preprocess(nb, resources)
        else:
            #print("Applying CodeFoldingPreprocessor: disabled")
            return nb, resources 

@juhasch
Copy link
Copy Markdown
Member Author

juhasch commented Aug 22, 2017

Thanks, I guess this doesn't hurt.

Maybe I should change the unicode symbol '↔' for folding back to an ascii one '<->'.
The pygment highlighter (rightly I guess) marks it as an arrow.

folded = cell['metadata']['code_folding']
if len(folded) > 0:
cell.source = self.fold_cell(cell.source, folded)
if self.remove_folded_code:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this check necessary, given the check in the preprocess method above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants