diff --git a/src/jupytext/cell_reader.py b/src/jupytext/cell_reader.py index e4ea21c1..9e7dedfc 100644 --- a/src/jupytext/cell_reader.py +++ b/src/jupytext/cell_reader.py @@ -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] diff --git a/tests/functional/simple_notebooks/test_read_simple_rmd.py b/tests/functional/simple_notebooks/test_read_simple_rmd.py index ee10f3ba..56958a19 100644 --- a/tests/functional/simple_notebooks/test_read_simple_rmd.py +++ b/tests/functional/simple_notebooks/test_read_simple_rmd.py @@ -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)