From f5e0f484b1d555edaeb1e998867a4b9266dea761 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 12 Sep 2024 22:07:11 +0300 Subject: Add util functions for fetching and rendering markdown as html. --- gn2/wqflask/api/markdown.py | 19 +++++++++++++------ 1 file 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): -- cgit v1.2.3