fix(minor): fix routing and titles + added frappe.utils.markdown alias to frappe.utils.md_to_html

This commit is contained in:
Rushabh Mehta 2021-01-31 18:18:47 +05:30
parent 4148fbfad5
commit bca3aecdaf
4 changed files with 11 additions and 8 deletions

View file

@ -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);
}
},

View file

@ -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) {

View file

@ -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)

View file

@ -290,6 +290,7 @@ VALID_UTILS = (
"strip",
"to_markdown",
"md_to_html",
"markdown",
"is_subset",
"generate_hash",
"formatdate",