Skip to content

Commit

Permalink
Implement support for frozen cells #101
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Oct 18, 2018
1 parent f6bc63c commit cd4aff2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion jupytext/cell_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def rmd_options_to_metadata(options):
for name in metadata:
try_eval_metadata(metadata, name)

if 'active' in metadata and 'eval' in metadata:
if ('active' in metadata or metadata.get('run_control', {}).get('frozen') is True) and 'eval' in metadata:
del metadata['eval']

return language, metadata
Expand Down Expand Up @@ -316,6 +316,8 @@ def metadata_to_json_options(metadata):

def is_active(ext, metadata):
"""Is the cell active for the given file extension?"""
if metadata.get('run_control', {}).get('frozen') is True:
return False
if 'active' not in metadata:
return True
return ext.replace('.', '') in re.split('\\.|,', metadata['active'])
Expand Down
5 changes: 2 additions & 3 deletions jupytext/cell_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ def find_cell_content(self, lines):
self.metadata['lines_to_end_of_cell_marker'] = 2

# Is this a raw cell?
if not is_active('ipynb', self.metadata) or (
self.ext == '.md' and self.cell_type == 'code'
and self.language is None):
if ('active' in self.metadata and not is_active('ipynb', self.metadata)) or \
(self.ext == '.md' and self.cell_type == 'code' and self.language is None):
if self.metadata.get('active') == '':
del self.metadata['active']
self.cell_type = 'raw'
Expand Down

0 comments on commit cd4aff2

Please sign in to comment.