Skip to content

Commit a668575

Browse files
committed
fix(footnotes): adjust styling for multiline footnotes; resolves #24
1 parent 39aef75 commit a668575

3 files changed

Lines changed: 40 additions & 17 deletions

File tree

content/markdown-demo.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ Footnote example[^1]
7777

7878
Some other footnote that is inline[^2]. As you can see, it just blends right in!
7979

80+
See below for an example of a footnote with multiple paragraphs and code[^3].
81+
8082
## Lists
8183

8284
### Unordered List
@@ -130,3 +132,15 @@ wrapping the text in square brackets and the URL in parentheses.
130132
occaecat voluptate
131133

132134
[^2]: Wikipedia article on a cool topic: [https://en.wikipedia.org/wiki/Isometric_projection](https://en.wikipedia.org/wiki/Isometric_projection)
135+
136+
[^3]:
137+
Here's one with multiple paragraphs and code. This is the first paragraph
138+
of the footnote.
139+
140+
Indent paragraphs to include them in the footnote.
141+
142+
```python
143+
print("Hello word")
144+
```
145+
146+
Add as many paragraphs as you like.

sass/_theme.scss

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,33 +224,38 @@ article [itemprop="summary"] p {
224224

225225

226226
.footnote-definition {
227-
flex-wrap: nowrap;
228-
display: flex;
229-
flex-direction: row;
230-
align-items: start;
231-
gap: 10px;
227+
display: block;
232228
max-width: 100%;
229+
margin-bottom: 10px;
230+
overflow: hidden;
233231
overflow-x: auto;
234-
margin: 5px 0;
232+
margin: 20px 0;
235233
padding-block-end: 5px;
236234

237235
sup {
236+
display: inline-block;
237+
margin-right: 0.5em;
238238
color: #ff2e88;
239239
font-size: inherit;
240240
font-weight: bold;
241241
vertical-align: baseline;
242-
}
243242

244-
sup::before {
245-
content: "["
243+
&::before {
244+
content: "[";
245+
}
246+
247+
&::after {
248+
content: "]";
249+
}
246250
}
247251

248-
sup::after {
249-
content: "]"
252+
p:first-of-type {
253+
display: inline;
250254
}
251255

252-
p {
253-
margin: 0;
256+
// Add top margin to subsequent p elements
257+
p:not(:first-of-type) {
258+
margin-top: 0.5em;
254259
}
255260
}
256261

static/js/reference-return.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ document.addEventListener("DOMContentLoaded", function () {
2727
returnLink.setAttribute("role", "link");
2828
returnLink.setAttribute("tabindex", "0");
2929

30-
// Append to the p tag
31-
const p = fn.querySelector("p");
32-
if (!p) return;
33-
p.appendChild(returnLink);
30+
// Append to the last p tag
31+
const lastParagraph = fn.querySelector("p:last-of-type");
32+
if (lastParagraph) {
33+
lastParagraph.appendChild(returnLink);
34+
} else {
35+
// If no paragraph, append to the footnote definition directly
36+
fn.appendChild(returnLink);
37+
}
3438
});
3539
});

0 commit comments

Comments
 (0)