From 1ba68f281fb012f3b576d2b1b0d6eb4435dbf585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Fredrik=20Ki=C3=A6r?= <31612826+anders-kiaer@users.noreply.github.com> Date: Mon, 17 Jun 2019 16:09:19 +0200 Subject: [PATCH] Make Markdown portable (#44) --- webviz_config/containers/_markdown.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webviz_config/containers/_markdown.py b/webviz_config/containers/_markdown.py index 64c07d3d..865e59ff 100644 --- a/webviz_config/containers/_markdown.py +++ b/webviz_config/containers/_markdown.py @@ -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): @@ -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( @@ -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