Skip to content

Commit 6a6bfeb

Browse files
tools: Bad conversion between github quote blocks and readme quote blocks (#11)
1 parent ed33b0f commit 6a6bfeb

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

tools/github_readme_sync/readme.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ def replace_path(match):
230230

231231
def convert_note_tags(self, body: str) -> str:
232232
conversions = {
233-
r">\s*\[!NOTE\]\s*": "> 📘 ",
234-
r">\s*\[!TIP\]\s*": "> 👍 ",
235-
r">\s*\[!IMPORTANT\]\s*": "> 📘 ",
236-
r">\s*\[!WARNING\]\s*": "> 🚧 ",
237-
r">\s*\[!CAUTION\]\s*": "> ❗️ ",
233+
r"\[!NOTE\]": "📘",
234+
r"\[!TIP\]": "👍",
235+
r"\[!IMPORTANT\]": "📘",
236+
r"\[!WARNING\]": "🚧",
237+
r"\[!CAUTION\]": "❗️",
238238
}
239239

240240
for old, new in conversions.items():

tools/github_readme_sync/tests/readme_test.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,24 @@ def test_correct_image_locations_no_repo_env(self):
429429
str(context.exception), "IMAGE_PATH environment variable not set"
430430
)
431431

432-
def test_convert_note_tags(self):
432+
def test_convert_note_tags_with_link(self):
433+
input_text = """
434+
> [!NOTE]
435+
> You can find our code at https://github.com/thousandbrainsproject/tbp.monty
436+
>
437+
> This is our open-source repository. We call it **Monty** after
438+
"""
439+
440+
expected_output = """
441+
> 📘
442+
> You can find our code at https://github.com/thousandbrainsproject/tbp.monty
443+
>
444+
> This is our open-source repository. We call it **Monty** after
445+
"""
446+
447+
self.assertEqual(
448+
self.readme.convert_note_tags(input_text).strip(), expected_output.strip()
449+
)
433450
input_text = """
434451
> [!NOTE] This is a note.
435452
> [!TIP] Here's a tip.
@@ -439,10 +456,10 @@ def test_convert_note_tags(self):
439456
"""
440457

441458
expected_output = """
442-
> 📘 This is a note.
443-
> 👍 Here's a tip.
444-
> 📘 This is important.
445-
> 🚧 This is a warning.
459+
> 📘 This is a note.
460+
> 👍 Here's a tip.
461+
> 📘 This is important.
462+
> 🚧 This is a warning.
446463
> ❗️ Be cautious!
447464
"""
448465

0 commit comments

Comments
 (0)