Skip to content

Commit

Permalink
Merge pull request #114 from krymtkts:feature/footnote
Browse files Browse the repository at this point in the history
Add support for footnotes in markdown parser.
  • Loading branch information
krymtkts authored Nov 19, 2023
2 parents 3655839 + 1b94c59 commit 069b63a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
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

0 comments on commit 069b63a

Please sign in to comment.