From 60bdf22c69795d75fd81a15ca4934d5e617c4ed4 Mon Sep 17 00:00:00 2001 From: 3y3 <3y3@ya.ru> Date: Wed, 14 Aug 2024 15:42:53 +0300 Subject: [PATCH] fix: Fix inline rendering beheavior --- src/transform/md.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/transform/md.ts b/src/transform/md.ts index d788b8fb..f5545604 100644 --- a/src/transform/md.ts +++ b/src/transform/md.ts @@ -121,9 +121,11 @@ function initCompiler(md: MarkdownIt, options: OptionsType, env: EnvType) { const {needToSanitizeHtml = true, renderInline = false, sanitizeOptions} = options; return (tokens: Token[]) => { - const html = renderInline - ? md.renderer.renderInline(tokens, md.options, env) - : md.renderer.render(tokens, md.options, env); + if (renderInline) { + tokens = tokens.filter((token) => token.type === 'inline'); + } + + const html = md.renderer.render(tokens, md.options, env); return needToSanitizeHtml ? sanitizeHtml(html, sanitizeOptions) : html; };