diff --git a/Shared/Article Rendering/main.js b/Shared/Article Rendering/main.js index 4edbac86b..73bbca4df 100644 --- a/Shared/Article Rendering/main.js +++ b/Shared/Article Rendering/main.js @@ -171,11 +171,13 @@ function error() { // Takes into account absoluting of URLs. function isLocalFootnote(target) { - return target.hash.startsWith("#fn") && target.href.indexOf(document.baseURI) === 0; + return (target.hash.startsWith("#fn") || target.hash.startsWith("#footnote")) && target.href.indexOf(document.baseURI) === 0; } function styleLocalFootnotes() { - for (elem of document.querySelectorAll("sup > a[href*='#fn'], sup > div > a[href*='#fn']")) { + // Multimarkdown-style: . Substack-style: a bare + // with no wrapper. + for (elem of document.querySelectorAll("sup > a[href*='#fn'], sup > div > a[href*='#fn'], a[id^='footnote-anchor-']")) { if (isLocalFootnote(elem)) { elem.classList.add("footnote"); } diff --git a/Shared/Article Rendering/newsfoot.js b/Shared/Article Rendering/newsfoot.js index 9f1dae3f6..765c06bd0 100644 --- a/Shared/Article Rendering/newsfoot.js +++ b/Shared/Article Rendering/newsfoot.js @@ -125,12 +125,37 @@ if (!target.hash) return; return decodeURIComponent(target.hash.substring(1)); } - /** @type {{fnref(target:HTMLAnchorElement): string|undefined}[]} */ + /** + * @type {{ + * fnref(target:HTMLAnchorElement): string|undefined, + * content(targetElement:HTMLElement): string + * }[]} + */ const footnoteFormats = [ + { // Substack: the ref + // points at a backlink N whose note text lives + // in the sibling elements that follow it, not inside the anchor. + fnref(target) { + if (!target.matches("a[id^='footnote-anchor-']")) return; + return idFromHash(target); + }, + content(targetElement) { + let html = ""; + let node = targetElement.nextElementSibling; + while (node && !node.matches("a[id^='footnote-']")) { + html += node.outerHTML; + node = node.nextElementSibling; + } + return html; + } + }, { // Multimarkdown fnref(target) { if (!target.matches(".footnote")) return; return idFromHash(target); + }, + content(targetElement) { + return targetElement.innerHTML; } } ]; @@ -140,22 +165,26 @@ if (!(ev.target && ev.target instanceof HTMLAnchorElement)) return; let targetId = undefined; + let format = undefined; for(const f of footnoteFormats) { targetId = f.fnref(ev.target); - if (targetId) break; + if (targetId) { + format = f; + break; + } } if (targetId === undefined) return; - + // Only override the default behaviour when we know we can find the // target element const targetElement = document.getElementById(targetId); if (targetElement === null) return; - + ev.preventDefault(); installContainer(ev.target); - - void new Footnote(targetElement.innerHTML, ev.target); + + void new Footnote(format.content(targetElement), ev.target); }); // Handle clicks on the footnote reverse link diff --git a/Shared/Article Rendering/stylesheet.css b/Shared/Article Rendering/stylesheet.css index 486deff3f..d0b3a76b9 100644 --- a/Shared/Article Rendering/stylesheet.css +++ b/Shared/Article Rendering/stylesheet.css @@ -154,6 +154,10 @@ body > .systemMessage { letter-spacing: 0em; } +.articleTitle, .articleDateline, .articleDatelineTitle, .articleBody { + text-autospace: normal; +} + .articleBody { margin-top: 20px; line-height: 1.6em; diff --git a/Themes/Tiqoe Dark.nnwtheme/stylesheet.css b/Themes/Tiqoe Dark.nnwtheme/stylesheet.css index 92f73e426..bbfa2634f 100644 --- a/Themes/Tiqoe Dark.nnwtheme/stylesheet.css +++ b/Themes/Tiqoe Dark.nnwtheme/stylesheet.css @@ -3,7 +3,7 @@ body { margin-left: auto; margin-right: auto; - word-wrap: break-word; + overflow-wrap: break-word; max-width: 44em; background-color: #17120f; color: #c5c2c1; @@ -16,7 +16,14 @@ body { text-underline-offset: 0.15em; } -[href]:has(img):hover { +a[href]:hover, +.headerContainer a[href]:hover { + text-shadow: 0 1px rgba(0, 0, 0, 2); + opacity: 0.8; + color: color-mix(in hsl, var(--link-underline-color), firebrick 70%); +} + +a[href]:has(img):hover { opacity: 1; } @@ -180,11 +187,8 @@ pre { margin: 0; overflow: auto; overflow-y: hidden; - word-wrap: normal; + overflow-wrap: normal; word-break: normal; -} - -pre { line-height: 1.4286em; } @@ -377,14 +381,22 @@ a.footnote:hover, margin-bottom: 20px; padding-left: 20px; padding-right: 20px; - + font-family: Charter, Georgia, sans-serif; word-break: break-word; -webkit-hyphens: auto; -webkit-text-size-adjust: none; - font-family: Charter, Georgia, sans-serif; font-size: calc([[font-size]]px + 2px); } + figcaption { + font-size: calc([[font-size]]px + 0px); + } + + code, + pre { + font-size: calc([[font-size]]px - 2px); + } + .articleTitle h1 { font-size: 1.5em; } @@ -398,14 +410,6 @@ a.footnote:hover, border: 1px solid var(--secondary-accent-color); } - code, - pre { - font-size: calc([[font-size]]px - 2px); - } - - figcaption { - font-size: calc([[font-size]]px + 0px); - } } /* macOS Specific */ @@ -420,67 +424,67 @@ a.footnote:hover, .smallText { font-size: 14px; + + figcaption { + font-size: 12px; + } + + code, + pre { + font-size: 10px; + } } - - .smallText code, - .smallText pre { - font-size: 10px; - } - - .smallText figcaption { - font-size: 12px; - } - + .mediumText { font-size: 16px; + + figcaption { + font-size: 14px; + } + + code, + pre { + font-size: 12px; + } } - - .mediumText code, - .mediumText pre { - font-size: 12px; - } - - .mediumText figcaption { - font-size: 14px; - } - + .largeText { font-size: 18px; - } - - .largeText code, - .largeText pre { - font-size: 14px; - } - - .largeText figcaption { - font-size: 16px; + + figcaption { + font-size: 16px; + } + + code, + pre { + font-size: 14px; + } } .xlargeText { font-size: 20px; - } - - .xlargeText code, - .xlargeText pre { - font-size: 16px; - } - - .xlargeText figcaption { - font-size: 18px; + + figcaption { + font-size: 18px; + } + + code, + pre { + font-size: 16px; + } } .xxlargeText { font-size: 22px; - } - - .xxlargeText code, - .xxlargeText pre { - font-size: 18px; - } - - .xxlargeText figcaption { - font-size: 20px; + + figcaption { + font-size: 20px; + } + + code, + pre { + font-size: 18px; + } } pre { @@ -493,6 +497,7 @@ a.footnote:hover, } } +/* Substack */ .image-link-expand .icon-container svg { stroke: #aaa; } @@ -503,9 +508,19 @@ a.footnote:hover, stroke: color-mix(in hsl, var(--link-underline-color), firebrick 70%) } -[href]:hover, -.headerContainer a[href]:hover { - text-shadow: 0 1px rgba(0, 0, 0, 2); - opacity: 0.8; - color: color-mix(in hsl, var(--link-underline-color), firebrick 70%); +/* WordPress */ +.wp-block-math:has(> math[display="block"]) { + overflow-x: auto; + border: 1px solid var(--secondary-accent-color); + padding: 10px; +} + +/* SVG */ +:is(div, figure):has(> svg:only-child) { + overflow-x: auto; +} + +/* PBS News Hour → Reader View */ +.inline-invite.inline-invite-type__funding.inline-invite-style__default:has(> .inline-invite-funding__box):has([href*="give.newshour.org"]) { + display: none; }