-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: update marked (and add marked-highlight)
- Loading branch information
1 parent
13b885f
commit 7704339
Showing
5 changed files
with
40 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Marked } from 'marked' | ||
import { markedHighlight } from 'marked-highlight' | ||
import hljs from 'highlight.js' | ||
|
||
// See example in https://www.npmjs.com/package/marked-highlight | ||
const marked = new Marked( | ||
markedHighlight({ | ||
langPrefix: 'hljs language-', | ||
highlight(code, lang) { | ||
const language = hljs.getLanguage(lang) ? lang : 'plaintext'; | ||
return hljs.highlight(code, { language }).value; | ||
} | ||
}) | ||
); | ||
|
||
export const stringToMarkdown = (s: string): string => | ||
// @ts-ignore the above `marked` isn't async but the parse has a return | ||
// type of string | Promise<string> just in case so TS is annoyed | ||
marked.parse(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters