diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-10-31 15:47:49 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-10-31 15:47:49 +0100 |
| commit | f547c97072881069417acd3b79b08fb7ecf40ba2 (patch) | |
| tree | 9d860b14be6bb4fae746e48f3dbdab00b28f6625 /src/library/text/link.rs | |
| parent | 671ce3dedd40067bb5cea84fe0739de013827053 (diff) | |
Reduce usage of `finalize`
Diffstat (limited to 'src/library/text/link.rs')
| -rw-r--r-- | src/library/text/link.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/library/text/link.rs b/src/library/text/link.rs index 98a867a8..11d55956 100644 --- a/src/library/text/link.rs +++ b/src/library/text/link.rs @@ -73,17 +73,21 @@ impl Show for LinkNode { } fn realize(&self, _: Tracked<dyn World>, _: StyleChain) -> SourceResult<Content> { - Ok(self.body.clone().unwrap_or_else(|| match &self.dest { - Destination::Url(url) => { - let mut text = url.as_str(); - for prefix in ["mailto:", "tel:"] { - text = text.trim_start_matches(prefix); + Ok(self + .body + .clone() + .unwrap_or_else(|| match &self.dest { + Destination::Url(url) => { + let mut text = url.as_str(); + for prefix in ["mailto:", "tel:"] { + text = text.trim_start_matches(prefix); + } + let shorter = text.len() < url.len(); + Content::Text(if shorter { text.into() } else { url.clone() }) } - let shorter = text.len() < url.len(); - Content::Text(if shorter { text.into() } else { url.clone() }) - } - Destination::Internal(_) => Content::Empty, - })) + Destination::Internal(_) => Content::Empty, + }) + .styled(TextNode::LINK, Some(self.dest.clone()))) } fn finalize( @@ -93,8 +97,6 @@ impl Show for LinkNode { mut realized: Content, ) -> SourceResult<Content> { let mut map = StyleMap::new(); - map.set(TextNode::LINK, Some(self.dest.clone())); - if let Smart::Custom(fill) = styles.get(Self::FILL) { map.set(TextNode::FILL, fill); } |
