Skip to content

Commit

Permalink
bibliography entry in Rmd document is not code (#1175)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts authored Nov 27, 2023
1 parent 9fac6f3 commit 7522609
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/jupytext/cell_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ def find_cell_end(self, lines):
return i - 1, i, False
return i, i, False

if self.start_code_re.match(line):
if self.start_code_re.match(line) and not line.startswith(
"```{bibliography}"
):
# Cells with a .noeval attribute are markdown cells #347
_, metadata = self.options_to_metadata(
self.start_code_re.findall(line)[0]
Expand Down
17 changes: 17 additions & 0 deletions tests/functional/simple_notebooks/test_read_simple_rmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,20 @@ def test_commented_triple_quote_1060(line):
compare(rmd2, rmd)
nb2 = jupytext.reads(rmd, fmt="Rmd")
compare_notebooks(nb2, nb)


def test_bibliography_in_rmd(
rmd="""Issue #1161
The bibliography section below should not
become a code cell
```{bibliography}
```
""",
):
nb = jupytext.reads(rmd, fmt="Rmd")
assert len(nb.cells) == 1, nb.cells
assert nb.cells[0].cell_type == "markdown"
rmd2 = jupytext.writes(nb, fmt="Rmd")
compare(rmd2, rmd)

0 comments on commit 7522609

Please sign in to comment.