Spaces:
Runtime error
Runtime error
derek-thomas
commited on
Commit
·
31a4689
1
Parent(s):
250025d
Fixing spoiler tags
Browse files- src/build_nomic.py +3 -2
src/build_nomic.py
CHANGED
@@ -19,6 +19,7 @@ logger = setup_logger(__name__)
|
|
19 |
|
20 |
# Regex to extract subreddit
|
21 |
subreddit_re = re.compile(r'r/(\w+)')
|
|
|
22 |
|
23 |
|
24 |
def count_words(text):
|
@@ -32,8 +33,8 @@ def preprocess_markdown(text):
|
|
32 |
hover_style = 'color: inherit;' # Assuming you want the text to be visible on hover
|
33 |
|
34 |
# Replace Reddit spoiler tags with an HTML span with inline styles
|
35 |
-
text =
|
36 |
-
r'\>\!(.*?)
|
37 |
r'<span class="spoiler" style="' + spoiler_style + '" onmouseover="this.style.color=\'' + hover_style + '\'" onmouseout="this.style.color=\'black\'">\1</span>',
|
38 |
text
|
39 |
)
|
|
|
19 |
|
20 |
# Regex to extract subreddit
|
21 |
subreddit_re = re.compile(r'r/(\w+)')
|
22 |
+
spoiler_re = re.compile(r'\>\!(.*?)\<\!',)
|
23 |
|
24 |
|
25 |
def count_words(text):
|
|
|
33 |
hover_style = 'color: inherit;' # Assuming you want the text to be visible on hover
|
34 |
|
35 |
# Replace Reddit spoiler tags with an HTML span with inline styles
|
36 |
+
text = spoiler_re.sub(
|
37 |
+
r'\>\!(.*?)\!\<',
|
38 |
r'<span class="spoiler" style="' + spoiler_style + '" onmouseover="this.style.color=\'' + hover_style + '\'" onmouseout="this.style.color=\'black\'">\1</span>',
|
39 |
text
|
40 |
)
|