Skip to content

Commit

Permalink
Resolve upstream issue with void tags in Dash Markdown (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
anders-kiaer authored Apr 23, 2020
1 parent b66b7f8 commit ec959d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions examples/example-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
Hi from a Markdown text file containing Norwegian letters (æ ø å), some
**bold** letters, _italic_ letters. _You can also **combine** them._

---

Horizontal line splitting two paragraphs.

#### An unordered list

* Item 1
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
},
entry_points={"console_scripts": ["webviz=webviz_config.command_line:main"]},
install_requires=[
# Pinning dash to the 1.7-series as long as
# https://github.com/plotly/dash-core-components/issues/746 is open
"dash==1.7",
"bleach>=3.1",
"cryptography>=2.4",
"dash>=1.7",
"flask-caching>=1.4",
"flask-talisman>=0.6",
"jinja2>=2.10",
Expand Down
6 changes: 6 additions & 0 deletions webviz_config/plugins/_markdown.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from pathlib import Path
from typing import List
from xml.etree import ElementTree # nosec
Expand Down Expand Up @@ -175,6 +176,11 @@ def __init__(self, markdown_file: Path):
styles=Markdown.ALLOWED_STYLES,
)

# Workaround for upstream issue https://github.com/plotly/dash-core-components/issues/746,
# where we convert void html tags from <tag> to <tag/>.
self.html = re.sub("<img (.*?[^/])>", r"<img \1/>", self.html)
self.html = self.html.replace("<br>", "<br/>").replace("<hr>", "<hr/>")

def add_webvizstore(self) -> List[tuple]:
return [(get_path, [{"path": self.markdown_file}])]

Expand Down

0 comments on commit ec959d4

Please sign in to comment.