diff --git a/.changeset/gold-games-tickle.md b/.changeset/gold-games-tickle.md new file mode 100644 index 0000000000..9ed24b9051 --- /dev/null +++ b/.changeset/gold-games-tickle.md @@ -0,0 +1,5 @@ +--- +"@primer/css": minor +--- + +Adding footnote styles to markdown-body. diff --git a/docs/content/components/markdown.md b/docs/content/components/markdown.md index 36d328936b..baf1c4146f 100644 --- a/docs/content/components/markdown.md +++ b/docs/content/components/markdown.md @@ -276,6 +276,25 @@ bundle: markdown
+ Here's a simple footnote,1 and here's a longer one.2 +
+ +This is the final element on the page and there should be no margin below this.
```
@@ -447,6 +466,18 @@ Large images should always scale down and fit in the content container.

+Here's a simple footnote,[^1] and here's a longer one.[^bignote]
+
+[^1]: This is the first footnote.
+
+[^bignote]: Here's one with multiple paragraphs and code.
+
+ Indent paragraphs to include them in the footnote.
+
+ `{ my code }`
+
+ Add as many paragraphs as you like.
+
```
This is the final element on the page and there should be no margin below this.
```
diff --git a/src/markdown/footnotes.scss b/src/markdown/footnotes.scss
new file mode 100644
index 0000000000..1afe6b60bb
--- /dev/null
+++ b/src/markdown/footnotes.scss
@@ -0,0 +1,37 @@
+// stylelint-disable selector-max-type
+// stylelint-disable selector-max-compound-selectors
+
+.markdown-body .footnotes {
+ font-size: $h6-size;
+ color: var(--color-fg-muted);
+ border-top: $border;
+
+ ol {
+ padding-left: $spacer-3;
+ }
+
+ li {
+ position: relative;
+ }
+
+ li:target::before {
+ position: absolute;
+ top: -$spacer-2;
+ right: -$spacer-2;
+ bottom: -$spacer-2;
+ left: -$spacer-4;
+ pointer-events: none;
+ content: "";
+ // stylelint-disable-next-line primer/borders
+ border: 2px $border-style var(--color-accent-emphasis);
+ border-radius: $border-radius;
+ }
+
+ li:target {
+ color: var(--color-fg-default);
+ }
+
+ .data-footnote-backref g-emoji {
+ font-family: monospace;
+ }
+}
diff --git a/src/markdown/index.scss b/src/markdown/index.scss
index b2e8d3d70b..4b33529c2b 100644
--- a/src/markdown/index.scss
+++ b/src/markdown/index.scss
@@ -6,3 +6,4 @@
@import "./images.scss";
@import "./code.scss";
@import "./blob-csv.scss";
+@import "./footnotes.scss";
diff --git a/src/markdown/markdown-body.scss b/src/markdown/markdown-body.scss
index 10e7fcdf4c..e5423e0e39 100644
--- a/src/markdown/markdown-body.scss
+++ b/src/markdown/markdown-body.scss
@@ -93,4 +93,12 @@
margin-bottom: 0;
}
}
+
+ sup > a::before {
+ content: "[";
+ }
+
+ sup > a::after {
+ content: "]";
+ }
}