Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix codefolding preprocessor configuration #1058

Merged
merged 4 commits into from
Aug 23, 2017

Conversation

juhasch
Copy link
Member

@juhasch juhasch commented Aug 22, 2017

Adresses #1047:

Adds configurable traitlets CodeFoldingPreprocessor.remove_folded_codeand
CodeFoldingPreprocessor.fold_mark.

@jfbercher
Copy link
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
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
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
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