mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 18:55:29 -05:00
Fix py-markdown plugin (#1008)
* fix wrong console method and unescape the tag content before running markdown on it * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add markdown plugin example test * add PyMarkdown minimal test * remove commented code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove import of console from pyscript * remove unused imports * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import html
|
||||
from textwrap import dedent
|
||||
|
||||
from js import console
|
||||
from markdown import markdown
|
||||
from pyscript import Plugin, console
|
||||
from pyscript import Plugin
|
||||
|
||||
console.warning(
|
||||
console.warn(
|
||||
"WARNING: This plugin is still in a very experimental phase and will likely change"
|
||||
" and potentially break in the future releases. Use it with caution."
|
||||
)
|
||||
@@ -26,6 +28,7 @@ class PyMarkdown:
|
||||
self.element = element
|
||||
|
||||
def connect(self):
|
||||
self.element.innerHTML = markdown(
|
||||
dedent(self.element.source), extensions=["fenced_code"]
|
||||
)
|
||||
unescaped_content = html.unescape(self.element.originalInnerHTML)
|
||||
original = dedent(unescaped_content)
|
||||
inner = markdown(original, extensions=["fenced_code"])
|
||||
self.element.innerHTML = inner
|
||||
|
||||
Reference in New Issue
Block a user