Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The bibliography entry in Rmd documents is not code #1175

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
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
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)
Loading