Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,22 +14,21 @@ bnb_config = BitsAndBytesConfig(load_in_8bit=True)
|
|
14 |
|
15 |
|
16 |
def convert_to_markdown(input_text):
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
return formatted_output.strip()
|
33 |
|
34 |
|
35 |
@spaces.GPU
|
|
|
14 |
|
15 |
|
16 |
def convert_to_markdown(input_text):
|
17 |
+
input_text = input_text.replace("!:", ":")
|
18 |
+
|
19 |
+
# Find all words before ': **' and replace with bold markdown
|
20 |
+
output_text = re.sub(r'(\w+)\s*:\s*\*\*', r'**\1**:', input_text)
|
21 |
+
|
22 |
+
# Replace double asterisks with double hashtags for remaining headings
|
23 |
+
output_text = output_text.replace("**", "##")
|
24 |
+
|
25 |
+
# Remove any extra whitespace at the beginning of lines
|
26 |
+
output_text = re.sub(r'^\s+', '', output_text, flags=re.MULTILINE)
|
27 |
+
|
28 |
+
# Add an extra newline after each heading (after the colon)
|
29 |
+
output_text = "## " + re.sub(r'(##\s*.*):', r'\1:\n\n', output_text)
|
30 |
+
|
31 |
+
return output_text
|
|
|
32 |
|
33 |
|
34 |
@spaces.GPU
|