file: parse .gmi files as gemtext
This commit is contained in:
parent
04c66bad52
commit
843a88659f
|
@ -35,7 +35,11 @@ def open_file(browser: Browser, filepath: str, encoding="utf-8"):
|
||||||
except (OSError, ValueError) as exc:
|
except (OSError, ValueError) as exc:
|
||||||
browser.set_status_error(f"Failed to open file: {exc}")
|
browser.set_status_error(f"Failed to open file: {exc}")
|
||||||
return None
|
return None
|
||||||
browser.load_page(Page.from_text(text))
|
if path.suffix == ".gmi":
|
||||||
|
page = Page.from_gemtext(text, browser.config["text_width"])
|
||||||
|
else:
|
||||||
|
page = Page.from_text(text)
|
||||||
|
browser.load_page(page)
|
||||||
elif path.is_dir():
|
elif path.is_dir():
|
||||||
gemtext = str(path) + "\n\n"
|
gemtext = str(path) + "\n\n"
|
||||||
for entry in sorted(path.iterdir()):
|
for entry in sorted(path.iterdir()):
|
||||||
|
|
Reference in a new issue