From 66f4ab80a5dbfa8634c3a5df91a59a9119f57b2c Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Thu, 26 Nov 2020 17:18:35 +0300 Subject: add table extension to support conversion of markdown tables to HTML --- wqflask/wqflask/markdown_routes.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/wqflask/wqflask/markdown_routes.py b/wqflask/wqflask/markdown_routes.py index 5170fcf0..073370c7 100644 --- a/wqflask/wqflask/markdown_routes.py +++ b/wqflask/wqflask/markdown_routes.py @@ -20,7 +20,24 @@ github_url = ("https://raw.githubusercontent.com/" + +def render_markdown_table(file_name,github_url="https://raw.githubusercontent.com/Alexanderlacuna/gn-docs/feature/add-markdown-pages/"): + + md_content=md_content=requests.get(f"{github_url}{file_name}") + if md_content.status_code==200: + return markdown.markdown(md_content.content.decode("utf-8"), extensions=['tables']) + 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") + + + + def render_markdown(file_name,github_url="https://raw.githubusercontent.com/Alexanderlacuna/gn-docs/feature/add-markdown-pages/"): + github_url = ("https://raw.githubusercontent.com/" + "genenetwork/gn-docs/master/") md_content=requests.get(f"{github_url}{file_name}") """Try to fetch the file name from Github and if that fails, try to @@ -60,7 +77,7 @@ def references(): @environments_blueprint.route("/") def environments(): - return render_template("environments.html", rendered_markdown=render_markdown("general/links/links.md")) + return render_template("environment.html", rendered_markdown=render_markdown_table("general/environments/environments.md")),200 @links_blueprint.route("/") -- cgit v1.2.3