Skip to content

Commit

Permalink
fix callout note
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchobben committed Aug 18, 2024
1 parent f3f9290 commit 0c20dc8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/eo_datascience/clean_nb.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,8 @@ def convert_callout_notes(dir="./notebooks", save=True):
return nb

def quarto_note_replace(quarto):
note_rst_start = """```{eval-rst}
.. note::
"""
note_rst_end = """.. include:: ./include-rst.rst
```
"""
note_rst_start = r":::{note}"
note_rst_end = r":::"
nts = re.findall(r"(?<=:::\s\{\.callout\-note\})[^:::]+", quarto)
for i in nts:
quarto = re.sub(r":::\s\{\.callout\-note\}" + re.escape(i) + r":::", note_rst_start + i + note_rst_end, quarto)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_quarto_nb_conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ def test_conversion_of_refs():
assert convert_refs("./tests", False)["cells"][2]["source"] == r"lorem ipsum {cite:p}`anon2024` and {cite:p}`anon2025` and lorem ipsum {cite:t}`anon2024` and {cite:t}`anon2025`"

def test_conversion_of_callout_notes():
rst = '```{eval-rst}\n.. note::\n\nThis a callout note.\n.. include:: ./include-rst.rst\n```\n'
rst = ':::{note}\nThis a callout note.\n:::'
assert quarto_note_replace(r"::: {.callout-note}\nThis a callout note.\n:::") == rst
assert convert_callout_notes("./tests", False)["cells"][1]["source"] == rst

0 comments on commit 0c20dc8

Please sign in to comment.