-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_formatter.py
More file actions
29 lines (22 loc) · 986 Bytes
/
test_formatter.py
File metadata and controls
29 lines (22 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import re
def convert_markdown_to_html(text):
"""Convert markdown-style bold (**text**) to HTML bold (<strong>text</strong>)"""
return re.sub(r'\*\*(.*?)\*\*', r'<strong>\1</strong>', text)
example_text = """
Question: Where did Lila grow up?
Answer: Lila grew up in a **bustling city**.
Question: What is the tone of the text?
Answer: The tone is **introspective and suggestive**. The text invites readers to reflect on their own life.
Question: What does the text imply about Lila's past?
Answer: The text **implies** that Lila had a positive or peaceful past experience in the countryside.
"""
html_text = convert_markdown_to_html(example_text)
print("ORIGINAL TEXT (with markdown):")
print(example_text)
print("\n" + "-"*50 + "\n")
print("CONVERTED TEXT (with HTML tags):")
print(html_text)
if "**" in html_text:
print("\nWARNING: Some markdown formatting was not converted!")
else:
print("\nSUCCESS: All markdown formatting was properly converted to HTML!")