diff --git a/system/ui/widgets/html_render.py b/system/ui/widgets/html_render.py
index 11163bd0aa..e3d87eb713 100644
--- a/system/ui/widgets/html_render.py
+++ b/system/ui/widgets/html_render.py
@@ -18,6 +18,7 @@ class ElementType(Enum):
H5 = "h5"
H6 = "h6"
P = "p"
+ LI = "li"
BR = "br"
@@ -31,6 +32,7 @@ class HtmlElement:
margin_top: int
margin_bottom: int
line_height: float = 1.2
+ indent_level: int = 0
class HtmlRenderer(Widget):
@@ -39,6 +41,7 @@ class HtmlRenderer(Widget):
self.elements: list[HtmlElement] = []
self._normal_font = gui_app.font(FontWeight.NORMAL)
self._bold_font = gui_app.font(FontWeight.BOLD)
+ self._list_indent_px = 40
self.styles: dict[ElementType, dict[str, Any]] = {
ElementType.H1: {"size": 68, "weight": FontWeight.BOLD, "color": rl.BLACK, "margin_top": 20, "margin_bottom": 16},
@@ -48,6 +51,7 @@ class HtmlRenderer(Widget):
ElementType.H5: {"size": 44, "weight": FontWeight.BOLD, "color": rl.BLACK, "margin_top": 12, "margin_bottom": 6},
ElementType.H6: {"size": 40, "weight": FontWeight.BOLD, "color": rl.BLACK, "margin_top": 10, "margin_bottom": 4},
ElementType.P: {"size": 38, "weight": FontWeight.NORMAL, "color": rl.Color(40, 40, 40, 255), "margin_top": 8, "margin_bottom": 12},
+ ElementType.LI: {"size": 38, "weight": FontWeight.NORMAL, "color": rl.Color(40, 40, 40, 255), "margin_top": 6, "margin_bottom": 6},
ElementType.BR: {"size": 0, "weight": FontWeight.NORMAL, "color": rl.BLACK, "margin_top": 0, "margin_bottom": 12},
}
@@ -72,30 +76,40 @@ class HtmlRenderer(Widget):
# Remove DOCTYPE, html, head, body tags but keep their content
html_content = re.sub(r']*>', '', html_content)
html_content = re.sub(r'?(?:html|head|body)[^>]*>', '', html_content)
+ # Keep UL tags to track nesting/indent
# Find all HTML elements
- pattern = r'<(h[1-6]|p)(?:[^>]*)>(.*?)\1>|
'
- matches = re.finditer(pattern, html_content, re.DOTALL | re.IGNORECASE)
-
- for match in matches:
- if match.group(0).lower().startswith('
]*>|)|<(h[1-6]|p|li)(?:[^>]*)>(.*?)\2>|
'
+ indent_level = 0
+ for match in re.finditer(pattern, html_content, re.DOTALL | re.IGNORECASE):
+ whole = match.group(0)
+ ul_tag = match.group(1)
+ tag = match.group(2)
+ content = match.group(3)
+
+ if whole.lower().startswith('
tags
self._add_element(ElementType.BR, "")
+ elif ul_tag is not None:
+ if ul_tag.lower().startswith('