diff --git a/frappe/public/js/frappe/router.js b/frappe/public/js/frappe/router.js index cc7411dc38..eec181650d 100644 --- a/frappe/public/js/frappe/router.js +++ b/frappe/public/js/frappe/router.js @@ -104,7 +104,7 @@ frappe.router = { this.current_route = this.parse(); this.set_history(sub_path); this.render(); - this.set_title(); + this.set_title(sub_path); this.trigger('change'); }, @@ -179,7 +179,6 @@ frappe.router = { set_history(sub_path) { frappe.route_history.push(this.current_route); - frappe.route_titles[sub_path] = frappe._original_title || document.title; frappe.ui.hide_open_dialog(); }, @@ -238,10 +237,6 @@ frappe.router = { set_title(sub_path) { if (frappe.route_titles[sub_path]) { frappe.utils.set_title(frappe.route_titles[sub_path]); - } else { - setTimeout(function() { - frappe.route_titles[frappe.get_route_str()] = frappe._original_title || document.title; - }, 1000); } }, diff --git a/frappe/public/js/frappe/utils/utils.js b/frappe/public/js/frappe/utils/utils.js index 2bf71dfd54..5f6126b81f 100644 --- a/frappe/public/js/frappe/utils/utils.js +++ b/frappe/public/js/frappe/utils/utils.js @@ -708,6 +708,10 @@ Object.assign(frappe.utils, { title = frappe._title_prefix + " " + title.replace(/<[^>]*>/g, ""); } document.title = title; + + // save for re-routing + const sub_path = frappe.router.get_sub_path(); + frappe.route_titles[sub_path] = title; }, set_title_prefix: function(prefix) { diff --git a/frappe/utils/data.py b/frappe/utils/data.py index 349ecfede1..c38d3ec027 100644 --- a/frappe/utils/data.py +++ b/frappe/utils/data.py @@ -15,7 +15,7 @@ from num2words import num2words from six.moves import html_parser as HTMLParser from six.moves.urllib.parse import quote, urljoin from html2text import html2text -from markdown2 import markdown, MarkdownError +from markdown2 import markdown as _markdown, MarkdownError from six import iteritems, text_type, string_types, integer_types from frappe.desk.utils import slug @@ -1329,12 +1329,15 @@ def md_to_html(markdown_text): html = None try: - html = markdown(markdown_text or '', extras=extras) + html = _markdown(markdown_text or '', extras=extras) except MarkdownError: pass return html +def markdown(markdown_text): + return md_to_html(markdown_text) + def is_subset(list_a, list_b): '''Returns whether list_a is a subset of list_b''' return len(list(set(list_a) & set(list_b))) == len(list_a) diff --git a/frappe/utils/safe_exec.py b/frappe/utils/safe_exec.py index 48f797a5a9..eac65e3f1d 100644 --- a/frappe/utils/safe_exec.py +++ b/frappe/utils/safe_exec.py @@ -290,6 +290,7 @@ VALID_UTILS = ( "strip", "to_markdown", "md_to_html", +"markdown", "is_subset", "generate_hash", "formatdate",