Colour href labels from hypersetup

This commit is contained in:
gloamxun committed 2026-10-26 02:38:41 +08:00
1 parent 8f429b892b
commit ea89bc1522
6 files changed
+58 -26

No files matched your search

+1
View File
@@ -6573,6 +6573,7 @@ mod tests {
font: ParagraphFont::Roman,
url: "https://example.com".into(),
text: "the site".into(),
color: None,
},
];
let style = crate::paragraph::ParagraphStyle {
+9 -1
View File
@@ -46,6 +46,7 @@ pub enum InlineSegment {
font: ParagraphFont,
url: String,
text: String,
color: Option<[u8; 3]>,
},
}
@@ -1767,7 +1768,12 @@ pub fn layout_paragraph_segments(segments: &[InlineSegment], style: &ParagraphSt
previous = Some((*font, text.clone()));
seen_content = true;
}
InlineSegment::Link { font, url, text } => {
InlineSegment::Link {
font,
url,
text,
color,
} => {
if text.is_empty() {
continue;
}
@@ -1798,6 +1804,7 @@ pub fn layout_paragraph_segments(segments: &[InlineSegment], style: &ParagraphSt
for item in &mut run {
if let HorizontalItem::Box(box_) = item {
box_.font = Some(*font);
box_.color = *color;
box_.link = Some(url.clone());
}
}
@@ -2110,6 +2117,7 @@ mod tests {
font: ParagraphFont::Roman,
url: "https://example.com".into(),
text: "there".into(),
color: None,
},
InlineSegment::Text(ParagraphFont::Roman, " now".into()),
];