about summary refs log tree commit diff
path: root/gn2/wqflask/api
diff options
context:
space:
mode:
authorAlexander_Kabui2024-09-12 22:07:11 +0300
committerAlexander_Kabui2024-09-12 22:07:11 +0300
commitf5e0f484b1d555edaeb1e998867a4b9266dea761 (patch)
tree0c4d794dda1e07f433b7d76cea287cb5b307e8da /gn2/wqflask/api
parente99b3942d1712725dcb3438161da743714b54348 (diff)
downloadgenenetwork2-f5e0f484b1d555edaeb1e998867a4b9266dea761.tar.gz
Add util functions for fetching and rendering markdown as html.
Diffstat (limited to 'gn2/wqflask/api')
-rw-r--r--gn2/wqflask/api/markdown.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/gn2/wqflask/api/markdown.py b/gn2/wqflask/api/markdown.py
index 0c8ba8f2..403eef72 100644
--- a/gn2/wqflask/api/markdown.py
+++ b/gn2/wqflask/api/markdown.py
@@ -29,12 +29,19 @@ xapian_syntax_blueprint = Blueprint("xapian_syntax_blueprint", __name__)
 blogs_blueprint = Blueprint("blogs_blueprint", __name__)
 
 
-def render_markdown_from_editor(file_path):
-    results = requests.get("http://localhost:8091/edit?file_path={file_path}")
-    results.raise_for_status()
-    text = results.json()["content"]
-    return markdown.markdown(text,
-                             extensions=['tables'])
+def fetch_raw_markdown(file_path):
+    """
+    This method fetches files from genenetwork:gn docs repo
+    """
+    # todo remove hardcoded file path
+    response = requests.get(f"http://localhost:8091/edit?file_path={file_path}")
+    response.raise_for_status()
+    return response.json()
+
+
+def render_markdown_as_html(content):
+    """This method converts markdown to html for render"""
+    return markdown.markdown(content, extensions=["tables"])
 
 
 def render_markdown(file_name, is_remote_file=True):