Skip to content

Commit 31751da

Browse files
committed
logger escape html in notebooks
1 parent 5dc3875 commit 31751da

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

client/labml/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.5.1'
1+
__version__ = '0.5.2'

client/labml/internal/logger/destinations/ipynb.py

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ def is_same_cell(self):
3333

3434
return False
3535

36+
@staticmethod
37+
def _escape_html(text: str) -> str:
38+
text = text.replace('&', '&')
39+
text = text.replace('<', '&lt;')
40+
text = text.replace('>', '&gt;')
41+
return text
42+
3643
@staticmethod
3744
def html_code(text: str, color: List[StyleCode] or StyleCode or None):
3845
"""
@@ -42,6 +49,8 @@ def html_code(text: str, color: List[StyleCode] or StyleCode or None):
4249
assert color is None
4350
return text
4451

52+
text = IpynbDestination._escape_html(text)
53+
4554
if color is None:
4655
return text
4756
elif isinstance(color, list):

0 commit comments

Comments
 (0)