Skip to content

Commit

Permalink
Reproduce and fix #1079
Browse files Browse the repository at this point in the history
  • Loading branch information
mwouts committed Jun 20, 2023
1 parent 54ea72e commit 150f9ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Jupytext ChangeLog
-------------------

**Fixed**
- Fix opening of notebooks with empty YAML header ([#1070](https://github.com/mwouts/jupytext/issues/1070))
- Fix opening notebooks with empty YAML header ([#1070](https://github.com/mwouts/jupytext/issues/1070))
- Fix single quote in double quote strings in R Markdown options ([#1079](https://github.com/mwouts/jupytext/issues/1079))


1.14.6 (2023-06-04)
Expand Down
4 changes: 2 additions & 2 deletions jupytext/cell_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ def count_special_chars(self, char, prev_char):
'Option line "{}" has too many '
"closing square brackets".format(self.line)
)
elif char == "'" and prev_char != "\\":
elif char == "'" and prev_char != "\\" and not self.in_double_quote:
self.in_single_quote = not self.in_single_quote
elif char == '"' and prev_char != "\\":
elif char == '"' and prev_char != "\\" and not self.in_single_quote:
self.in_double_quote = not self.in_double_quote


Expand Down
14 changes: 14 additions & 0 deletions tests/test_read_simple_rmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,17 @@ def test_pair_rmd_file_with_cell_tags_and_options(

# The new code chunk has the new code, and options are still there
compare(rmd2, rmd.replace("3", "4"))


def test_apostrophe_in_parameter_1079(
no_jupytext_version_number,
rmd="""```{python some-name, param="Problem's"}
a = 1
```
""",
):
nb = jupytext.reads(rmd, fmt="Rmd")
rmd2 = jupytext.writes(nb, fmt="Rmd")
compare(rmd2, rmd)
nb2 = jupytext.reads(rmd, fmt="Rmd")
compare_notebooks(nb2, nb)

0 comments on commit 150f9ac

Please sign in to comment.