From 49802fdcf6f6995772cef0287ce4fa1efee23890 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Wed, 30 Jul 2025 15:34:28 +0300 Subject: [PATCH] apply text styling to ul/ol --- Scripts/StyleManager.gd | 4 ++-- Scripts/Tags/ol.gd | 7 ++++--- Scripts/Tags/ul.gd | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Scripts/StyleManager.gd b/Scripts/StyleManager.gd index 60ba616..f71ff41 100644 --- a/Scripts/StyleManager.gd +++ b/Scripts/StyleManager.gd @@ -66,8 +66,8 @@ static func apply_element_styles(node: Control, element: HTMLParser.HTMLElement, return node -static func apply_styles_to_label(label: RichTextLabel, styles: Dictionary, element: HTMLParser.HTMLElement, parser) -> void: - var text = element.get_preserved_text() if element.tag_name == "pre" else element.get_bbcode_formatted_text(parser) +static func apply_styles_to_label(label: RichTextLabel, styles: Dictionary, element: HTMLParser.HTMLElement, parser, text_override: String = "") -> void: + var text = text_override if text_override != "" else (element.get_preserved_text() if element.tag_name == "pre" else element.get_bbcode_formatted_text(parser)) var font_size = 24 # default # Apply font size diff --git a/Scripts/Tags/ol.gd b/Scripts/Tags/ol.gd index 97f32c4..8b73681 100644 --- a/Scripts/Tags/ol.gd +++ b/Scripts/Tags/ol.gd @@ -30,7 +30,7 @@ func calculate_marker_width(list_type: String, max_index: int) -> float: add_child(temp_label) var marker_text = get_marker_for_type(list_type, max_index) - temp_label.text = "[font_size=24]%s[/font_size]" % marker_text + StyleManager.apply_styles_to_label(temp_label, {}, null, null, marker_text) await get_tree().process_frame @@ -55,7 +55,7 @@ func create_li_node(element: HTMLParser.HTMLElement, list_type: String, index: i marker_label.theme = BROWSER_TEXT var marker_text = get_marker_for_type(list_type, index) - marker_label.text = "[font_size=24]%s[/font_size]" % marker_text + StyleManager.apply_styles_to_label(marker_label, {}, null, null, marker_text) # Create content var content_label = RichTextLabel.new() @@ -65,7 +65,8 @@ func create_li_node(element: HTMLParser.HTMLElement, list_type: String, index: i content_label.scroll_active = false content_label.theme = BROWSER_TEXT - content_label.text = "[font_size=24]%s[/font_size]" % element.get_bbcode_formatted_text(parser) + var content_text = element.get_bbcode_formatted_text(parser) + StyleManager.apply_styles_to_label(content_label, {}, null, null, content_text) li_container.add_theme_constant_override("separation", 0) li_container.add_child(marker_label) diff --git a/Scripts/Tags/ul.gd b/Scripts/Tags/ul.gd index 3a84287..2f29960 100644 --- a/Scripts/Tags/ul.gd +++ b/Scripts/Tags/ul.gd @@ -23,7 +23,7 @@ func calculate_marker_width(list_type: String) -> float: add_child(temp_label) var bullet_text = get_bullet_for_type(list_type) - temp_label.text = "[font_size=24]%s[/font_size]" % bullet_text + StyleManager.apply_styles_to_label(temp_label, {}, null, null, bullet_text) await get_tree().process_frame @@ -50,7 +50,7 @@ func create_li_node(element: HTMLParser.HTMLElement, list_type: String, marker_w bullet_label.theme = BROWSER_TEXT var bullet_text = get_bullet_for_type(list_type) - bullet_label.text = "[font_size=24]%s[/font_size]" % bullet_text + StyleManager.apply_styles_to_label(bullet_label, {}, null, null, bullet_text) # Create content var content_label = RichTextLabel.new() @@ -59,7 +59,8 @@ func create_li_node(element: HTMLParser.HTMLElement, list_type: String, marker_w content_label.fit_content = true content_label.theme = BROWSER_TEXT content_label.scroll_active = false - content_label.text = "[font_size=24]%s[/font_size]" % element.get_bbcode_formatted_text(parser) + var content_text = element.get_bbcode_formatted_text(parser) + StyleManager.apply_styles_to_label(content_label, {}, null, null, content_text) li_container.add_theme_constant_override("separation", 0) li_container.add_child(bullet_label)