mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
add load_resources to markdown
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Markdown module to generate web/HTML components from Markdown code"""
|
||||
from pyscript import document, window
|
||||
from pyweb.ui.elements import TextElementBase
|
||||
|
||||
from pyweb import pydom
|
||||
from pyweb.ui.elements import TextElementBase, script
|
||||
|
||||
class markdown(TextElementBase):
|
||||
"""Markdown component to render HTML from Markdown code"""
|
||||
@@ -10,5 +10,17 @@ class markdown(TextElementBase):
|
||||
|
||||
def __init__(self, content, style=None, **kwargs):
|
||||
# TODO: We should sanitize the content!!!!!
|
||||
|
||||
html = window.marked.parse(content)
|
||||
super().__init__(html, style=style, **kwargs)
|
||||
|
||||
# TODO: DON'T KNOW WHY BUT THIS DOESN'T WORK
|
||||
def load_resources(parent=None):
|
||||
if parent is None:
|
||||
parent = pydom.body
|
||||
|
||||
parent.append(
|
||||
script(src="https://cdn.jsdelivr.net/npm/marked@11.1.1/lib/marked.umd.min.js"),
|
||||
)
|
||||
|
||||
# load_resources()
|
||||
@@ -378,7 +378,7 @@ class Icon(ShoeBase):
|
||||
# <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.12.0/cdn/themes/light.css" />
|
||||
# <script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.12.0/cdn/shoelace-autoloader.js"></script>
|
||||
def load_resources(parent=None):
|
||||
print("Loading resources...")
|
||||
print("Loading shoelace resources...")
|
||||
if parent is None:
|
||||
parent = pydom.body
|
||||
parent.append(
|
||||
|
||||
Reference in New Issue
Block a user