From 77f1fa9eb05aee8917840c2d9caf10262347684b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 21 Jun 2026 10:27:53 -0300 Subject: content: linkExternal: only breakout long link content --- src/content/dependencies/linkExternal.js | 40 +++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js index 5bfad5f4..ddb828a1 100644 --- a/src/content/dependencies/linkExternal.js +++ b/src/content/dependencies/linkExternal.js @@ -124,7 +124,7 @@ export default { }); let linkContent; - if (urlIsValid) { + if (urlIsValid) validContent: { // For valid URLs, the annotation (if any) is already handled // by formatExternalLink. It is not shown at all, in up-front // presentation, if there is custom content. @@ -133,14 +133,24 @@ export default { if (html.isBlank(slots.content)) { linkContent = formattedLink; - } else if (slots.fromContent) { - linkContent = - html.metatag('breakout', - slots.content); - } else { - linkContent = slots.content; + break validContent; } - } else { + + if (slots.fromContent) { + const text = + html.resolve(slots.content, {type: 'plain'}); + + if (text.split(' ').length >= 4 || text.length >= 24) { + linkContent = + html.metatag('breakout', + slots.content); + + break validContent; + } + } + + linkContent = slots.content; + } else invalidContent: { // For invalid URLs, there is no automatically formatted link, // and the annotation (if any) is rolled into presentation below. // However, it's still not shown if there is custom content. @@ -152,16 +162,18 @@ export default { link: html.tag('i', language.$('misc.external.invalidURL.annotation')), annotation: language.sanitize(data.annotation), }); + break invalidContent; } else { linkContent = html.tag('i', language.$('misc.external.invalidURL')); + break invalidContent; } - } else { - linkContent = - language.$('misc.external.withAnnotation', { - link: slots.content, - annotation: html.tag('i', language.$('misc.external.invalidURL.annotation')), - }); } + + linkContent = + language.$('misc.external.withAnnotation', { + link: slots.content, + annotation: html.tag('i', language.$('misc.external.invalidURL.annotation')), + }); } if (slots.fromContent) { -- cgit 1.3.0-6-gf8a5