1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

cargo fmt

This commit is contained in:
Kumpelinus 2025-03-10 13:13:30 +01:00
parent df5ae7ebbe
commit b302a8c4cb
2 changed files with 26 additions and 9 deletions

View file

@ -140,7 +140,8 @@ impl FormattedText {
for component in self.clone().into_iter() {
let component_style = &component.get_base().style;
// Calculate the effective style by merging the running style with the component's style.
// Calculate the effective style by merging the running style with the
// component's style.
let effective_style = running_style.merged_with(component_style);
let style_string = effective_style.get_html_style();
@ -151,7 +152,8 @@ impl FormattedText {
Ok(text) => text.to_string(),
Err(_) => c.key.to_string(),
},
}.replace("\n", "<br>");
}
.replace("\n", "<br>");
// Append the styled span for this component.
html_output.push_str(&format!(
@ -170,8 +172,6 @@ impl FormattedText {
html_output
}
}
impl IntoIterator for FormattedText {

View file

@ -560,7 +560,8 @@ impl Style {
}
/// Returns a new style that is a merge of self and other.
/// For any field that `other` does not specify (is None), selfs value is used.
/// For any field that `other` does not specify (is None), selfs value is
/// used.
pub fn merged_with(&self, other: &Style) -> Style {
Style {
color: other.color.clone().or(self.color.clone()),
@ -597,16 +598,32 @@ impl Style {
style.push_str(&format!("color: {};", color.format_value()));
}
if let Some(bold) = self.bold {
style.push_str(&format!("font-weight: {};", if bold { "bold" } else { "normal" }));
style.push_str(&format!(
"font-weight: {};",
if bold { "bold" } else { "normal" }
));
}
if let Some(italic) = self.italic {
style.push_str(&format!("font-style: {};", if italic { "italic" } else { "normal" }));
style.push_str(&format!(
"font-style: {};",
if italic { "italic" } else { "normal" }
));
}
if let Some(underlined) = self.underlined {
style.push_str(&format!("text-decoration: {};", if underlined { "underline" } else { "none" }));
style.push_str(&format!(
"text-decoration: {};",
if underlined { "underline" } else { "none" }
));
}
if let Some(strikethrough) = self.strikethrough {
style.push_str(&format!("text-decoration: {};", if strikethrough { "line-through" } else { "none" }));
style.push_str(&format!(
"text-decoration: {};",
if strikethrough {
"line-through"
} else {
"none"
}
));
}
if let Some(obfuscated) = self.obfuscated {
if obfuscated {