diff --git a/package.json b/package.json index 7437cc4..199da64 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "iconv-lite": "^0.6.3", "listr": "^0.14.3", "marked": "4.2.2", + "mermaid": "^9.2.2", "puppeteer": ">=8.0.0", "semver": "^7.3.7", "serve-handler": "^6.1.3" diff --git a/src/lib/config.ts b/src/lib/config.ts index a1e1c06..7120c33 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -1,8 +1,10 @@ import { WatchOptions } from 'chokidar'; import { GrayMatterOption } from 'gray-matter'; -import { marked } from 'marked'; +import { marked, Renderer } from 'marked'; +import { MermaidConfig } from 'mermaid'; import { resolve } from 'path'; import { FrameAddScriptTagOptions, launch, PDFOptions } from 'puppeteer'; +import { renderer } from './renderer'; export const defaultConfig: Config = { basedir: process.cwd(), @@ -13,7 +15,15 @@ export const defaultConfig: Config = { body_class: [], page_media_type: 'screen', highlight_style: 'github', - marked_options: {}, + marked_options: { + /** + * Ingore Typscript here since boolean and string are incompatible + * see: https://marked.js.org/using_pro#renderer + * Returning false continues the original renderer behaviour + */ + // @ts-ignore + renderer: renderer + }, pdf_options: { printBackground: true, format: 'a4', @@ -37,7 +47,8 @@ export const defaultConfig: Config = { stylesheet_encoding: 'utf-8', as_html: false, devtools: false, - marked_extensions: [], + marked_extensions: {}, + mermaid_config: {} }; /** @@ -172,7 +183,12 @@ interface BasicConfig { * * @see https://marked.js.org/using_pro#extensions */ - marked_extensions: marked.MarkedExtension[]; + marked_extensions: marked.MarkedExtension + + /** + * Mermaid Configuration + */ + mermaid_config: MermaidConfig } export type PuppeteerLaunchOptions = Parameters[0]; diff --git a/src/lib/get-html.ts b/src/lib/get-html.ts index 738b11c..bf36147 100644 --- a/src/lib/get-html.ts +++ b/src/lib/get-html.ts @@ -10,5 +10,7 @@ export const getHtml = (md: string, config: Config) => ` ${getMarked(config.marked_options, config.marked_extensions)(md)} + +