How to use the jupytext.cell_metadata.metadata_to_text function in jupytext

To help you get started, we’ve selected a few jupytext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mwouts / jupytext / tests / test_cell_metadata.py View on Github external
def test_language_metadata_no_space(text='python{"a":1}', value=('python', {'a': 1})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == 'python a=1'
github mwouts / jupytext / tests / test_cell_metadata.py View on Github external
def test_language_and_attribute(text="python .class", value=('python', {'.class': None})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
github mwouts / jupytext / tests / test_cell_metadata.py View on Github external
def test_attribute(allow_title):
    text = ".class"
    value = ('', {'.class': None})
    compare(text_to_metadata(text, allow_title), value)
    assert metadata_to_text(*value) == text
github mwouts / jupytext / tests / test_cell_metadata.py View on Github external
def test_simple_metadata_with_spaces(text='python string = "value" number = 1.0 array = ["a",  "b"]',
                                     value=('python', {'string': 'value', 'number': 1.0, 'array': ['a', 'b']})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == 'python string="value" number=1.0 array=["a", "b"]'
github mwouts / jupytext / tests / test_cell_metadata.py View on Github external
def test_no_language(text='.class', value=('', {'.class': None})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
github mwouts / jupytext / tests / test_cell_metadata.py View on Github external
def test_only_metadata(text='key="value"', value=('', {'key': 'value'})):
    compare(text_to_metadata(text), value)
    assert metadata_to_text(*value) == text
github mwouts / jupytext / jupytext / cell_to_text.py View on Github external
def html_comment(self, metadata, code='region'):
        """Protect a Markdown or Raw cell with HTML comments"""
        if metadata:
            region_start = ['']
            region_start = ' '.join(region_start)
        else:
            region_start = ''.format(code)

        return [region_start] + self.source + [''.format(code)]
github mwouts / jupytext / jupytext / cell_to_text.py View on Github external
def code_to_text(self):
        """Return the text representation of a code cell"""
        source = copy(self.source)
        comment_magic(source, self.language, self.comment_magics)

        if self.metadata.get('active') == '':
            self.metadata.pop('active')

        self.language = self.metadata.pop('language', self.language)
        if self.cell_type == 'raw' and not is_active(self.ext, self.metadata, False):
            return self.html_comment(self.metadata, 'raw')

        options = metadata_to_text(self.language, self.metadata)
        return ['```' + options] + source + ['```']