Skip to content

Commit

Permalink
Backward compatibility with #419
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Jan 26, 2021
1 parent 07feede commit 47bc33d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 9 additions & 0 deletions jupytext/cell_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,20 @@ def find_cell_end(self, lines):
prev_blank = 0
else:
self.cell_type = "code"
# At some point we could remove the below, in which we make sure not to break language strings
# into multiple cells (#419). Indeed, now that the markdown cell uses one extra backtick (#712)
# we should not have the issue any more
parser = StringParser(self.language or self.default_language)
for i, line in enumerate(lines):
# skip cell header
if i == 0:
continue

if parser.is_quoted():
parser.read_line(line)
continue

parser.read_line(line)
if self.end_code_re.match(line):
return i, i + 1, True

Expand Down
7 changes: 4 additions & 3 deletions tests/test_read_simple_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def test_two_markdown_cell_with_no_language_code_works(


def test_markdown_cell_with_code_inside_multiline_string_419(
text='''````python
text='''```python
readme = """
above
Expand All @@ -776,11 +776,12 @@ def test_markdown_cell_with_code_inside_multiline_string_419(
below
"""
````
```
''',
):
"""A code cell containing triple backticks is converted to a code cell encapsulated with four backticks"""
nb = jupytext.reads(text, "md")
compare(jupytext.writes(nb, "md"), text)
compare(jupytext.writes(nb, "md"), "`" + text[:-1] + "`\n")
assert len(nb.cells) == 1


Expand Down

0 comments on commit 47bc33d

Please sign in to comment.