Strip YAML frontmatter when rendering README in Documentation tab
Browse files
app.py
CHANGED
|
@@ -90,6 +90,12 @@ def create_interface(module):
|
|
| 90 |
readme_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md")
|
| 91 |
with open(readme_path) as f:
|
| 92 |
readme = f.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
def update_preview(name):
|
| 95 |
ex = EXAMPLES[name]
|
|
|
|
| 90 |
readme_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md")
|
| 91 |
with open(readme_path) as f:
|
| 92 |
readme = f.read()
|
| 93 |
+
# Strip YAML frontmatter — HF Space requires it at the top of README.md
|
| 94 |
+
# for metadata, but it would render as raw text in the Documentation tab.
|
| 95 |
+
if readme.startswith("---"):
|
| 96 |
+
end = readme.find("\n---", 3)
|
| 97 |
+
if end != -1:
|
| 98 |
+
readme = readme[end + 4:].lstrip()
|
| 99 |
|
| 100 |
def update_preview(name):
|
| 101 |
ex = EXAMPLES[name]
|