diff --git a/src/lib/config.ts b/src/lib/config.ts index 02843c2..b8c6418 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -37,6 +37,7 @@ export const defaultConfig: Config = { stylesheet_encoding: 'utf-8', as_html: false, devtools: false, + marked_extensions: [], }; /** @@ -165,6 +166,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. + * + * @see https://marked.js.org/using_pro#extensions + */ + marked_extensions: marked.MarkedExtension[]; } export type PuppeteerLaunchOptions = Parameters[0]; diff --git a/src/lib/get-html.ts b/src/lib/get-html.ts index e03145f..738b11c 100644 --- a/src/lib/get-html.ts +++ b/src/lib/get-html.ts @@ -8,7 +8,7 @@ export const getHtml = (md: string, config: Config) => ` ${config.document_title} - ${getMarked(config.marked_options)(md)} + ${getMarked(config.marked_options, config.marked_extensions)(md)} `; diff --git a/src/lib/get-marked-with-highlighter.ts b/src/lib/get-marked-with-highlighter.ts index 0f8a7a9..49a8d2f 100644 --- a/src/lib/get-marked-with-highlighter.ts +++ b/src/lib/get-marked-with-highlighter.ts @@ -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[]) => { marked.setOptions({ highlight: (code, languageName) => { const language = hljs.getLanguage(languageName) ? languageName : 'plaintext'; @@ -11,6 +11,6 @@ export const getMarked = (options: marked.MarkedOptions) => { langPrefix: 'hljs ', ...options, }); - + marked.use(...extensions); return marked; };