|
|
|
@ -27,7 +27,6 @@ class HtmlElement: |
|
|
|
|
content: str |
|
|
|
|
font_size: int |
|
|
|
|
font_weight: FontWeight |
|
|
|
|
color: rl.Color |
|
|
|
|
margin_top: int |
|
|
|
|
margin_bottom: int |
|
|
|
|
line_height: float = 1.2 |
|
|
|
@ -41,14 +40,14 @@ class HtmlRenderer(Widget): |
|
|
|
|
self._bold_font = gui_app.font(FontWeight.BOLD) |
|
|
|
|
|
|
|
|
|
self.styles: dict[ElementType, dict[str, Any]] = { |
|
|
|
|
ElementType.H1: {"size": 68, "weight": FontWeight.BOLD, "color": rl.BLACK, "margin_top": 20, "margin_bottom": 16}, |
|
|
|
|
ElementType.H2: {"size": 60, "weight": FontWeight.BOLD, "color": rl.BLACK, "margin_top": 24, "margin_bottom": 12}, |
|
|
|
|
ElementType.H3: {"size": 52, "weight": FontWeight.BOLD, "color": rl.BLACK, "margin_top": 20, "margin_bottom": 10}, |
|
|
|
|
ElementType.H4: {"size": 48, "weight": FontWeight.BOLD, "color": rl.BLACK, "margin_top": 16, "margin_bottom": 8}, |
|
|
|
|
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.BR: {"size": 0, "weight": FontWeight.NORMAL, "color": rl.BLACK, "margin_top": 0, "margin_bottom": 12}, |
|
|
|
|
ElementType.H1: {"size": 68, "weight": FontWeight.BOLD, "margin_top": 20, "margin_bottom": 16}, |
|
|
|
|
ElementType.H2: {"size": 60, "weight": FontWeight.BOLD, "margin_top": 24, "margin_bottom": 12}, |
|
|
|
|
ElementType.H3: {"size": 52, "weight": FontWeight.BOLD, "margin_top": 20, "margin_bottom": 10}, |
|
|
|
|
ElementType.H4: {"size": 48, "weight": FontWeight.BOLD, "margin_top": 16, "margin_bottom": 8}, |
|
|
|
|
ElementType.H5: {"size": 44, "weight": FontWeight.BOLD, "margin_top": 12, "margin_bottom": 6}, |
|
|
|
|
ElementType.H6: {"size": 40, "weight": FontWeight.BOLD, "margin_top": 10, "margin_bottom": 4}, |
|
|
|
|
ElementType.P: {"size": 38, "weight": FontWeight.NORMAL, "margin_top": 8, "margin_bottom": 12}, |
|
|
|
|
ElementType.BR: {"size": 0, "weight": FontWeight.NORMAL, "margin_top": 0, "margin_bottom": 12}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if file_path is not None: |
|
|
|
@ -101,7 +100,6 @@ class HtmlRenderer(Widget): |
|
|
|
|
content=content, |
|
|
|
|
font_size=style["size"], |
|
|
|
|
font_weight=style["weight"], |
|
|
|
|
color=style["color"], |
|
|
|
|
margin_top=style["margin_top"], |
|
|
|
|
margin_bottom=style["margin_bottom"], |
|
|
|
|
) |
|
|
|
|