From 369db18d95ef1e6f6c2e39ab1c08b30d2bf99a9e Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Tue, 2 Apr 2024 11:57:10 +0800 Subject: [PATCH] fix: figcaption only works within figure (#279) --- lib/renderer.js | 4 ++-- test/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/renderer.js b/lib/renderer.js index 92ef7f7..cb6a232 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -137,8 +137,8 @@ class Renderer extends MarkedRenderer { if (lazyload) out += ' loading="lazy"'; out += '>'; - if (figcaption) { - if (text) out += ``; + if (figcaption && text) { + return `
${out}
`; } return out; } diff --git a/test/index.js b/test/index.js index 89610a0..42b3dac 100644 --- a/test/index.js +++ b/test/index.js @@ -806,8 +806,8 @@ describe('Marked renderer', () => { result.should.eql([ '

', - 'foo

', - 'foo

\n' + '
foo
', + '
foo

\n' ].join('\n')); });