From 5d9ebd1a99a1d894efb9a4795c4059b2223c5f7c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 16 Sep 2019 21:48:32 -0400 Subject: [PATCH] Add Markdown footnotes --- lib/markdown.ts | 3 +++ package-lock.json | 5 +++++ package.json | 1 + site/css/main.scss | 12 ++++++++++++ 4 files changed, 21 insertions(+) diff --git a/lib/markdown.ts b/lib/markdown.ts index 04d2851..7a06afa 100644 --- a/lib/markdown.ts +++ b/lib/markdown.ts @@ -1,4 +1,5 @@ import MarkdownIt from "markdown-it"; +import MarkdownItFootnote from "markdown-it-footnote"; import slugify from "@sindresorhus/slugify"; import * as util from "./util"; @@ -8,6 +9,8 @@ const md = new MarkdownIt({ typographer: true }); +md.use(MarkdownItFootnote); + // Inserts heading anchors // Based on https://github.com/valeriangalliat/markdown-it-anchor md.core.ruler.push("anchor", (state) => { diff --git a/package-lock.json b/package-lock.json index 18b6dcd..a66b9ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1467,6 +1467,11 @@ "uc.micro": "^1.0.5" } }, + "markdown-it-footnote": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/markdown-it-footnote/-/markdown-it-footnote-3.0.2.tgz", + "integrity": "sha512-JVW6fCmZWjvMdDQSbOT3nnOQtd9iAXmw7hTSh26+v42BnvXeVyGMDBm5b/EZocMed2MbCAHiTX632vY0FyGB8A==" + }, "mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", diff --git a/package.json b/package.json index 2ebe221..7aad4e7 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "express": "^4.16.4", "highlight.js": "^9.13.1", "markdown-it": "^8.4.2", + "markdown-it-footnote": "^3.0.2", "morgan": "^1.9.1", "node-sass": "^4.12.0", "pg": "^7.11.0", diff --git a/site/css/main.scss b/site/css/main.scss index 3a01d66..76fd402 100644 --- a/site/css/main.scss +++ b/site/css/main.scss @@ -101,6 +101,13 @@ article { h1 { font-size: 1.8rem; } h2 { font-size: 1.6rem; } + hr.footnotes-sep { + border: none; + height: 1px; + background: var(--accent-color); + } + + // Markdown decorations @media (min-width: 768px) { a::before { content: "["; } a::after { content: "](" attr(href) ")"; word-wrap: break-word; } @@ -110,6 +117,11 @@ article { font-size: 14px; } a { text-decoration: none; } + sup.footnote-ref > a::before, + sup.footnote-ref > a::after, + a.footnote-backref::before, a.footnote-backref::after { + content: ""; + } } code::before, code::after { content: "`";