Skip to content

Commit

Permalink
Make Markdown portable (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer authored Jun 17, 2019
1 parent a793fcf commit 1ba68f2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion webviz_config/containers/_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dash_core_components as html
from . import WebvizContainer
from ..webviz_assets import webviz_assets
from ..webviz_store import webvizstore


class _WebvizMarkdownExtension(Extension):
Expand Down Expand Up @@ -105,9 +106,12 @@ class Markdown(WebvizContainer):
ALLOWED_STYLES = ['width', 'height']

def __init__(self, markdown_file: Path):

self.markdown_file = markdown_file

self.html = bleach.clean(
markdown.markdown(
markdown_file.read_text(),
get_path(self.markdown_file).read_text(),
extensions=['tables',
'sane_lists',
_WebvizMarkdownExtension(
Expand All @@ -118,6 +122,14 @@ def __init__(self, markdown_file: Path):
styles=Markdown.ALLOWED_STYLES
)

def add_webvizstore(self):
return [(get_path, [{'path': self.markdown_file}])]

@property
def layout(self):
return html.Markdown(self.html, dangerously_allow_html=True)


@webvizstore
def get_path(path) -> Path:
return path

0 comments on commit 1ba68f2

Please sign in to comment.