This commit is contained in:
Brent Simmons committed 2026-10-06 21:12:00 -07:00
commit 7a2f27f324
4 files changed
+126 -76

No files matched your search

+4 -2
View File
@@ -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: <sup><a href="#fn…">. Substack-style: a bare
// <a id="footnote-anchor-N" href="#footnote-N"> with no <sup> 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");
}
+35 -6
View File
@@ -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 <a id="footnote-anchor-N" href="#footnote-N">
// points at a backlink <a id="footnote-N">N</a> 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
+4
View File
@@ -154,6 +154,10 @@ body > .systemMessage {
letter-spacing: 0em;
}
.articleTitle, .articleDateline, .articleDatelineTitle, .articleBody {
text-autospace: normal;
}
.articleBody {
margin-top: 20px;
line-height: 1.6em;
+83 -68
View File
@@ -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;
}