Skip to content

Commit

Permalink
Preserve jupytext specific cell metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Oct 23, 2018
1 parent b52e8ff commit c4845b2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions jupytext/cell_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def __init__(self, cell, default_language, ext, comment_magics=None, cell_metada
self.ext = ext
self.cell_type = cell.cell_type
self.source = cell_source(cell)
self.metadata = copy(cell.metadata)
filter_metadata(self.metadata, cell_metadata_filter, _IGNORE_CELL_METADATA)
self.unfiltered_metadata = cell.metadata
self.metadata = filter_metadata(copy(cell.metadata), cell_metadata_filter, _IGNORE_CELL_METADATA)
self.language = cell_language(self.source) or default_language
self.default_language = default_language
self.comment = _SCRIPT_EXTENSIONS.get(ext, {}).get('comment', '#')
Expand Down Expand Up @@ -159,6 +159,12 @@ class LightScriptCellExporter(BaseCellExporter):
"""A class that represent a notebook cell as a Python or Julia script"""
default_comment_magics = True

def __init__(self, *args, **kwargs):
BaseCellExporter.__init__(self, *args, **kwargs)
for key in ['endofcell']:
if key in self.unfiltered_metadata:
self.metadata[key] = self.unfiltered_metadata[key]

def is_code(self):
# Treat markdown cells with metadata as code cells (#66)
if self.cell_type == 'markdown' and self.metadata:
Expand Down Expand Up @@ -308,6 +314,10 @@ def __init__(self, *args, **kwargs):
BaseCellExporter.__init__(self, *args, **kwargs)
self.comment = '#'

for key in ['cell_marker']:
if key in self.unfiltered_metadata:
self.metadata[key] = self.unfiltered_metadata[key]

def code_to_text(self):
"""Not used"""
pass
Expand Down

0 comments on commit c4845b2

Please sign in to comment.