apply text styling to ul/ol

This commit is contained in:
Face
2025-07-30 15:34:28 +03:00
parent b7a73fe448
commit 49802fdcf6
3 changed files with 10 additions and 8 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)