Unmark icon- and badge-type external links as external
Marco Ricci

Marco Ricci commited on 2024-11-27 14:16:59
Zeige 1 geänderte Dateien mit 8 Einfügungen und 3 Löschungen.


Icon-/badge-only external links lose their visual succintness if they
include the external link marker afterwards.

Also use this opportunity to rewrite the external links CSS selectors
using the `:is` and `:has` pseudo-classes, which leads to much less code
repetition.  Supposedly, every major browser has had a release with
`:has` support since December 2023, so browser compatibility shouldn't
be a major issue.
... ...
@@ -5,9 +5,7 @@ div.doc-contents:not(.first) {
5 5
 }
6 6
 
7 7
 /* Mark external links as such. */
8
-div[data-md-component="content"] a[href^="https://"]::after,
9
-div[data-md-component="content"] a[href^="http://"]::after,
10
-div[data-md-component="content"] a[href^="//"]::after,
8
+div[data-md-component="content"] a:not(.md-icon):is([href^="https://"], [href^="http://"], [href^="//"])::after,
11 9
 a.external::after,
12 10
 a.autorefs-external::after {
13 11
   /* https://primer.style/octicons/arrow-up-right-24 */
... ...
@@ -24,6 +22,13 @@ a.autorefs-external::after {
24 22
   background-color: currentColor;
25 23
 }
26 24
 
25
+/* ... but don't mark badges as external */
26
+div[data-md-component="content"] a:not(.md-icon):is([href^="https://"], [href^="http://"], [href^="//"]):has(img[src^="https://img.shields.io/"], img[src="Keep_a_changelog-E05735.svg"], img[src="SemVer-3F4551.svg"])::after {
27
+    content: '';
28
+    width: 0em;
29
+    height: 0em;
30
+}
31
+
27 32
 a.external:hover::after,
28 33
 a.autorefs-external:hover::after {
29 34
   background-color: var(--md-accent-fg-color);
30 35