Skip to main content

Fix a bug in the Mastodon script

ID
1a9a795
date
2024-06-18 22:40:11+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
060e71c
message
Fix a bug in the Mastodon script
changed files
2 files, 5 additions

Changed files

textexpander/get_mastodon_text.py (2641) → textexpander/get_mastodon_text.py (2677)

diff --git a/textexpander/get_mastodon_text.py b/textexpander/get_mastodon_text.py
index 718c4d7..ad162ad 100755
--- a/textexpander/get_mastodon_text.py
+++ b/textexpander/get_mastodon_text.py
@@ -43,6 +43,7 @@ def download(url):
 def normalise_text(text: str) -> str:
     text = text.replace("</p><p>", "\n\n")
     text = text.replace("<p>", "").replace("</p>", "")
+    text = text.replace("*", "\\*")
     text = re.sub(
         r'<a href="[^"]+" class="mention hashtag" rel="tag">#<span>(?P<hashtag>[^<]+)</span></a>',
         r"\\#\g<hashtag>",

textexpander/test_get_mastodon_text.py (1198) → textexpander/test_get_mastodon_text.py (1481)

diff --git a/textexpander/test_get_mastodon_text.py b/textexpander/test_get_mastodon_text.py
index 5420b17..a390a6e 100644
--- a/textexpander/test_get_mastodon_text.py
+++ b/textexpander/test_get_mastodon_text.py
@@ -21,6 +21,10 @@ from get_mastodon_text import normalise_text
             "I realize it&#39;s (comparatively) super easy to set up",
             "I realize it's (comparatively) super easy to set up",
         ),
+        (
+            'The "this site is faster in the app" prompts have the benefit of truth *because they broke the website with React*',
+            'The "this site is faster in the app" prompts have the benefit of truth \*because they broke the website with React\*',
+        ),
     ],
 )
 def test_normalise_text(input, output):