diff options
author | BonfaceKilz | 2020-11-20 18:51:46 +0300 |
---|---|---|
committer | BonfaceKilz | 2020-11-20 18:51:46 +0300 |
commit | 0a6a5d0ac847489bb5db158bc54e73aa682e18a0 (patch) | |
tree | ff4a5294c801d09079b291fd15055703573e5d70 /wqflask | |
parent | 51f05b5fa896a2ed636ecb08bf69d929896db517 (diff) | |
download | genenetwork2-0a6a5d0ac847489bb5db158bc54e73aa682e18a0.tar.gz |
Replace mistunes with markdown library
* wqflask/wqflask/markdown_routes.py (render_markdown): Use markdown
library instead of mistunes.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/markdown_routes.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/wqflask/wqflask/markdown_routes.py b/wqflask/wqflask/markdown_routes.py index 48a1ea81..7a9fac41 100644 --- a/wqflask/wqflask/markdown_routes.py +++ b/wqflask/wqflask/markdown_routes.py @@ -2,9 +2,8 @@ Render pages from github, or if they are unavailable, look for it else where """ -import os import requests -import mistune +import markdown from flask import Blueprint from flask import render_template @@ -21,16 +20,20 @@ look for it inside the file system "genenetwork/gn-docs/master/") md_content = requests.get(f"{github_url}{file_name}") if md_content.status_code == 200: - return mistune.html(md_content.content.decode("utf-8")) + return markdown.Markdown().convert(md_content.content.decode("utf-8")) - with open(os.path.join(os.path.abspath(os.path.dirname(__file__)), - f"static/markdown/{file_name}")) as md_file: - markdown = md_file.read() - return mistune.html(markdown) + # TODO: Add fallback on our git server by checking the mirror. + + # Content not available + return (f"\nContent for {file_name} not available. " + "Please check " + "(here to see where content exists)" + "[https://github.com/genenetwork/gn-docs]. " + "Please reach out to the gn2 team to have a look at this") @glossary_blueprint.route('/') def glossary(): return render_template( "glossary.html", - rendered_markdown=render_markdown("glossary.md")), 200 + rendered_markdown=render_markdown("general/glossary/glossary.md")), 200 |