| ... | @@ -84,11 +84,13 @@ fn rewrite(html: &str, origin: &url::Url, profiles: &HashMap<String, Profile>) - | ... | @@ -84,11 +84,13 @@ fn rewrite(html: &str, origin: &url::Url, profiles: &HashMap<String, Profile>) - |
| 84 | element.set_attribute("href", &profile.url)?; | 84 | element.set_attribute("href", &profile.url)?; |
| 85 | element.set_attribute("target", "_blank")?; | 85 | element.set_attribute("target", "_blank")?; |
| 86 | element.set_attribute("rel", "noreferrer")?; | 86 | element.set_attribute("rel", "noreferrer")?; |
| | 87 | let style = element.get_attribute("style").unwrap_or_default(); |
| | 88 | element.set_attribute("style", &format!("{style};text-decoration-line:underline;text-decoration-color:currentColor"))?; |
| 87 | if let Some(picture) = &profile.picture { | 89 | if let Some(picture) = &profile.picture { |
| 88 | let picture = picture.replace('&', "&amp;").replace('"', "&quot;").replace('<', "&lt;"); | 90 | let picture = picture.replace('&', "&amp;").replace('"', "&quot;").replace('<', "&lt;"); |
| 89 | element.prepend(&format!("<img src=\"{picture}\" alt=\"\" width=\"16\" height=\"16\" referrerpolicy=\"no-referrer\" style=\"width:1em;height:1em;object-fit:cover;vertical-align:-.125em;margin-right:.3em\">"), ContentType::Html); | 91 | element.prepend(&format!("<img src=\"{picture}\" alt=\"\" width=\"16\" height=\"16\" referrerpolicy=\"no-referrer\" style=\"width:1em;height:1em;object-fit:cover;vertical-align:-.125em;margin-right:.3em\">"), ContentType::Html); |
| 90 | } | 92 | } |
| 91 | let icon = profile.icon.trim().replace("<svg ", "<svg aria-hidden=\"true\" focusable=\"false\" style=\"color:inherit;width:.85em;height:.85em;vertical-align:-.1em;margin-right:.15em\" "); | 93 | let icon = profile.icon.trim().replace("<svg ", "<svg aria-hidden=\"true\" focusable=\"false\" style=\"color:inherit;width:.85em;height:.85em;vertical-align:-.1em;margin-right:.05em\" "); |
| 92 | let icon = if profile.url.starts_with("https://github.com/") { icon.replace("<path ", "<path style=\"fill:currentColor;stroke:none\" ") } else { icon }; | 94 | let icon = if profile.url.starts_with("https://github.com/") { icon.replace("<path ", "<path style=\"fill:currentColor;stroke:none\" ") } else { icon }; |
| 93 | element.append(&icon, ContentType::Html); | 95 | element.append(&icon, ContentType::Html); |
| 94 | element.append(&profile.name, ContentType::Text); | 96 | element.append(&profile.name, ContentType::Text); |