-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
feat: pass custom extension to marked #127
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I've been wanting to do sth like that for a while anyway.
Please see the suggestions. Instead of using []
as a default in the function params, can you add marked_extensions: []
to the defaultConfig
in src/lib/config.ts
, please?
src/lib/config.ts
Outdated
@@ -165,6 +165,13 @@ interface BasicConfig { | |||
* This is specifically useful when running into issues when editor plugins trigger additional saves after the initial save. | |||
*/ | |||
watch_options?: WatchOptions; | |||
|
|||
/** | |||
* Custm Extensions to be passed to marked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Custm Extensions to be passed to marked | |
* Custom Extensions to be passed to marked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -1,7 +1,7 @@ | |||
import hljs from 'highlight.js'; | |||
import { marked } from 'marked'; | |||
|
|||
export const getMarked = (options: marked.MarkedOptions) => { | |||
export const getMarked = (options: marked.MarkedOptions, extensions: marked.MarkedExtension[] = []) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const getMarked = (options: marked.MarkedOptions, extensions: marked.MarkedExtension[] = []) => { | |
export const getMarked = (options: marked.MarkedOptions, extensions: marked.MarkedExtension[]) => { |
@@ -11,6 +11,6 @@ export const getMarked = (options: marked.MarkedOptions) => { | |||
langPrefix: 'hljs ', | |||
...options, | |||
}); | |||
|
|||
marked.use(...extensions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
marked.use(...extensions) | |
marked.use(...extensions); | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/lib/config.ts
Outdated
* | ||
* See https://marked.js.org/using_pro#extensions | ||
*/ | ||
extensions?: marked.MarkedExtension[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extensions?: marked.MarkedExtension[] | |
marked_extensions: marked.MarkedExtension[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/lib/get-html.ts
Outdated
@@ -8,7 +8,7 @@ export const getHtml = (md: string, config: Config) => `<!DOCTYPE html> | |||
<html> | |||
<head><title>${config.document_title}</title><meta charset="utf-8"></head> | |||
<body class="${config.body_class.join(' ')}"> | |||
${getMarked(config.marked_options)(md)} | |||
${getMarked(config.marked_options, config.extensions)(md)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
${getMarked(config.marked_options, config.extensions)(md)} | |
${getMarked(config.marked_options, config.marked_extensions)(md)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a couple style issues then it's good to go (:
Hey sorry somehow I never got around to releasing this 🙈 I just did, so with |
Ths PR allows the user to pass a custom extension to the marked parser.
see https://marked.js.org/using_pro#extensions