Moved convert_markdown_template to formatters

This commit is contained in:
Anastasia Gradova
2023-12-22 10:03:43 -07:00
parent 86af8fcaa4
commit 0989246334
2 changed files with 19 additions and 21 deletions

View File

@@ -6,11 +6,14 @@ from functools import partial
from math import floor, log10
from numbers import Number
import markdown
import os
import ago
import dateutil
import humanize
import pytz
from flask import Markup, url_for
from flask import Markup, url_for, render_template_string
from flask.helpers import get_root_path
from notifications_utils.field import Field
from notifications_utils.formatters import make_quotes_smart
from notifications_utils.formatters import nl2br as utils_nl2br
@@ -21,6 +24,18 @@ from app.utils.csv import get_user_preferred_timezone
from app.utils.time import parse_naive_dt
def convert_markdown_template(mdf):
APP_ROOT = get_root_path('notifications-admin')
file = 'app/content/' + mdf + '.md'
md_file = os.path.join(APP_ROOT, file)
with open(md_file) as f:
content_text = f.read()
md_render = markdown.markdown(content_text)
jn_render = render_template_string(md_render)
return jn_render
def convert_to_boolean(value):
if isinstance(value, str):
if value.lower() in ["t", "true", "on", "yes", "1"]: