Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for footnotes in markdown parser. #114

Merged
merged 3 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contents/posts/2023-02-01-about-markdown-parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ plain _italic_ **bold** `code` ~~strikethrough~~

Recommends to start Markdown headings from h2 because it render the blog title as h1.

footnote like this[^1]

[^1]: footnote line requires blank line before.

## blockquote

> blockquote
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
"dependencies": {
"highlight.js": "^11.9.0",
"marked": "^10.0.0",
"marked-footnote": "^1.1.2",
"marked-highlight": "^2.0.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"yaml": "^2.3.4"
}
}
}
5 changes: 4 additions & 1 deletion src/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module private Util =

let private me: ResizeArray<Marked.MarkedExtension> =
let markedHighlight: obj -> Marked.MarkedExtension = importMember "marked-highlight"
let markedFootnote: obj -> Marked.MarkedExtension = importDefault "marked-footnote"

let renderer =
let heading text level =
Expand Down Expand Up @@ -155,7 +156,9 @@ module private Util =

markedHighlight !!{| highlight = highlight |}

let mes = [ renderer; highlighter ]
let footNote = markedFootnote !!{| description = "<hr />" |}

let mes = [ renderer; highlighter; footNote ]
ResizeArray mes

marked.``use`` me
Expand Down