From b8db80a11ff1f6ebb013e0c062a02560bc986d1e Mon Sep 17 00:00:00 2001 From: 3y3 <3y3@ya.ru> Date: Tue, 19 Mar 2024 19:37:43 +0300 Subject: [PATCH] feat: Add transformInline method Fixes #393 --- src/transform/md.ts | 6 ++++-- src/transform/typings.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/transform/md.ts b/src/transform/md.ts index fd8fced1..d788b8fb 100644 --- a/src/transform/md.ts +++ b/src/transform/md.ts @@ -118,10 +118,12 @@ function initParser(md: MarkdownIt, options: OptionsType, env: EnvType) { } function initCompiler(md: MarkdownIt, options: OptionsType, env: EnvType) { - const {needToSanitizeHtml = true, sanitizeOptions} = options; + const {needToSanitizeHtml = true, renderInline = false, sanitizeOptions} = options; return (tokens: Token[]) => { - const html = md.renderer.render(tokens, md.options, env); + const html = renderInline + ? md.renderer.renderInline(tokens, md.options, env) + : md.renderer.render(tokens, md.options, env); return needToSanitizeHtml ? sanitizeHtml(html, sanitizeOptions) : html; }; diff --git a/src/transform/typings.ts b/src/transform/typings.ts index c8ff9e55..79ac76db 100644 --- a/src/transform/typings.ts +++ b/src/transform/typings.ts @@ -48,6 +48,7 @@ export interface OptionsType { rootPublicPath?: string; transformLink?: (href: string) => string; getPublicPath?: (options: OptionsType, href?: string) => string; + renderInline?: boolean; [x: string]: unknown; }