Skip to content
This repository was archived by the owner on Dec 9, 2022. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions mystify/convert.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
import json
import jinja
import yaml
import re
from myst_parser.main import default_parser

SOURCE = """
{source}
"""

OUTPUT = """
{output}
{{}}
"""

MARKDOWN = """
---
{{}}
---
"""

CODE = """
% cell
{{}}
{{}}
% endcell
"""

METADATA = """{metadata}
{{}}
"""

CELL_METADATA = """{cell_meta}
---
{{}}
---
"""

def to_myst(model):
pass
sections = model['cells']
model_metadata = model['metadata']


def to_model(myst):
md = default_parser("docutils")
tokens = md.parse(myst)
sections = _split_sections(tokens)
return sections


def _parse_code_output(cell_section):
Expand Down Expand Up @@ -48,11 +88,3 @@ def _split_sections(tokens):
sections['cells'].append(_parse_cell(append_to_cell))
append_to_cell = None
return sections


def to_model(myst):
md = default_parser("docutils")
tokens = md.parse(myst)
sections = _split_sections(tokens)
return sections