Spaces:
Sleeping
Sleeping
Victoria Oberascher
commited on
Commit
·
2662822
1
Parent(s):
2d9c467
update read markdown function
Browse files
app.py
CHANGED
|
@@ -5,7 +5,22 @@ import gradio as gr
|
|
| 5 |
|
| 6 |
def read_markdown(filepath):
|
| 7 |
with open(filepath, 'r') as file:
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
local_path = Path(sys.path[0])
|
|
|
|
| 5 |
|
| 6 |
def read_markdown(filepath):
|
| 7 |
with open(filepath, 'r') as file:
|
| 8 |
+
lines = file.readlines()
|
| 9 |
+
start_index = None
|
| 10 |
+
end_index = None
|
| 11 |
+
for i, line in enumerate(lines):
|
| 12 |
+
if line.strip() == '---':
|
| 13 |
+
if start_index is None:
|
| 14 |
+
start_index = i
|
| 15 |
+
else:
|
| 16 |
+
end_index = i
|
| 17 |
+
break
|
| 18 |
+
if end_index is None:
|
| 19 |
+
return ''.join(
|
| 20 |
+
lines) # If no end delimiter found, return entire content
|
| 21 |
+
else:
|
| 22 |
+
return ''.join(lines[end_index +
|
| 23 |
+
1:]) # Return content after end delimiter
|
| 24 |
|
| 25 |
|
| 26 |
local_path = Path(sys.path[0])
|