feat: image markdown extension
This commit is contained in:
@@ -232,7 +232,8 @@ lms_markdown_macro_renderers = {
|
|||||||
"Quiz": "lms.plugins.quiz_renderer",
|
"Quiz": "lms.plugins.quiz_renderer",
|
||||||
"YouTubeVideo": "lms.plugins.youtube_video_renderer",
|
"YouTubeVideo": "lms.plugins.youtube_video_renderer",
|
||||||
"Video": "lms.plugins.video_renderer",
|
"Video": "lms.plugins.video_renderer",
|
||||||
"Assignment": "lms.plugins.assignment_renderer"
|
"Assignment": "lms.plugins.assignment_renderer",
|
||||||
|
"Image": "lms.plugin.image_renderer"
|
||||||
}
|
}
|
||||||
|
|
||||||
# page_renderer to manage profile pages
|
# page_renderer to manage profile pages
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import html as HTML
|
|||||||
def markdown_to_html(text):
|
def markdown_to_html(text):
|
||||||
"""Renders markdown text into html.
|
"""Renders markdown text into html.
|
||||||
"""
|
"""
|
||||||
|
print(text)
|
||||||
return markdown.markdown(text, extensions=['fenced_code', MacroExtension()])
|
return markdown.markdown(text, extensions=['fenced_code', MacroExtension()])
|
||||||
|
|
||||||
def find_macros(text):
|
def find_macros(text):
|
||||||
@@ -105,7 +106,7 @@ def sanitize_html(html, macro):
|
|||||||
any broken tags. This makes sures that all those things are fixed
|
any broken tags. This makes sures that all those things are fixed
|
||||||
before passing to the etree parser.
|
before passing to the etree parser.
|
||||||
"""
|
"""
|
||||||
soup = BeautifulSoup(html, features="lxml")
|
soup = BeautifulSoup(html, features="html5lib")
|
||||||
nodes = soup.body.children
|
nodes = soup.body.children
|
||||||
classname = ""
|
classname = ""
|
||||||
if macro == "YouTubeVideo":
|
if macro == "YouTubeVideo":
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Web Form",
|
"doctype": "Web Form",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"introduction_text": "<div class=\"ql-editor read-mode\"><p><br></p><p><br></p><p>Create lessons for your course. You can add some additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.</p><p><br></p><table class=\"table table-bordered\"><tbody><tr><td data-row=\"row-wxk1\"><strong>Content Type</strong></td><td data-row=\"row-wxk1\"><strong>Syntax</strong></td></tr><tr><td data-row=\"row-lawj\">Video</td><td data-row=\"row-lawj\">{{ Video(\"url_of_source\") }}</td></tr><tr><td data-row=\"insert-table\">YouTube Video</td><td data-row=\"insert-table\">{{ YouTubeVideo(\"unique_embed_id\") }}</td></tr><tr><td data-row=\"insert-row-below\">Exercise</td><td data-row=\"insert-row-below\">{{ Exercise(\"exercise_name\") }}</td></tr><tr><td data-row=\"row-3b6n\">Quiz</td><td data-row=\"row-3b6n\">{{ Quiz(\"lms_quiz_name\") }}</td></tr><tr><td data-row=\"row-r57s\">Assignment</td><td data-row=\"row-r57s\">{{ Assignment(\"id-filetype\") }}</td></tr></tbody></table></div>",
|
"introduction_text": "<div class=\"ql-editor read-mode\"><p><br></p><p><br></p><p>Create lessons for your course. For adding content, use markdown syntax. You can add some additional content to the lesson using a special syntax. The table below mentions all types of dynamic content that you can add to the lessons and the syntax for the same.</p><p><br></p><table class=\"table table-bordered\"><tbody><tr><td data-row=\"row-wxk1\"><strong>Content Type</strong></td><td data-row=\"row-wxk1\"><strong>Syntax</strong></td></tr><tr><td data-row=\"row-lawj\">Video</td><td data-row=\"row-lawj\">{{ Video(\"url_of_source\") }}</td></tr><tr><td data-row=\"insert-table\">YouTube Video</td><td data-row=\"insert-table\">{{ YouTubeVideo(\"unique_embed_id\") }}</td></tr><tr><td data-row=\"insert-row-below\">Exercise</td><td data-row=\"insert-row-below\">{{ Exercise(\"exercise_name\") }}</td></tr><tr><td data-row=\"row-3b6n\">Quiz</td><td data-row=\"row-3b6n\">{{ Quiz(\"lms_quiz_name\") }}</td></tr><tr><td data-row=\"row-r57s\">Assignment</td><td data-row=\"row-r57s\">{{ Assignment(\"id-filetype\") }}</td></tr></tbody></table></div>",
|
||||||
"is_multi_step_form": 0,
|
"is_multi_step_form": 0,
|
||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"login_required": 1,
|
"login_required": 1,
|
||||||
"max_attachment_size": 0,
|
"max_attachment_size": 0,
|
||||||
"modified": "2022-03-14 18:49:33.526455",
|
"modified": "2022-04-20 15:45:55.567759",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "lesson",
|
"name": "lesson",
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
"fieldname": "body",
|
"fieldname": "body",
|
||||||
"fieldtype": "Text",
|
"fieldtype": "Text",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Body",
|
"label": "Content",
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
|
|||||||
@@ -142,3 +142,6 @@ def show_custom_signup():
|
|||||||
or frappe.db.get_single_value("LMS Settings", "privacy_policy")):
|
or frappe.db.get_single_value("LMS Settings", "privacy_policy")):
|
||||||
return "lms/templates/signup-form.html"
|
return "lms/templates/signup-form.html"
|
||||||
return "frappe/templates/signup.html"
|
return "frappe/templates/signup.html"
|
||||||
|
|
||||||
|
def image_renderer(src);
|
||||||
|
return f"<img src={src}>"
|
||||||
|
|||||||
Reference in New Issue
Block a user