Skip to content

Commit 369db18

Browse files
fix: figcaption only works within figure (#279)
1 parent 16b1fb0 commit 369db18

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/renderer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ class Renderer extends MarkedRenderer {
137137
if (lazyload) out += ' loading="lazy"';
138138

139139
out += '>';
140-
if (figcaption) {
141-
if (text) out += `<figcaption aria-hidden="true">${text}</figcaption>`;
140+
if (figcaption && text) {
141+
return `<figure>${out}<figcaption aria-hidden="true">${text}</figcaption></figure>`;
142142
}
143143
return out;
144144
}

test/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,8 @@ describe('Marked renderer', () => {
806806

807807
result.should.eql([
808808
'<p><img src="/bar/baz.jpg" title="bar">',
809-
'<img src="/bar/baz.jpg" alt="foo" title="bar"><figcaption aria-hidden="true">foo</figcaption>',
810-
'<img src="/aaa/bbb.jpg" alt="foo"><figcaption aria-hidden="true">foo</figcaption></p>\n'
809+
'<figure><img src="/bar/baz.jpg" alt="foo" title="bar"><figcaption aria-hidden="true">foo</figcaption></figure>',
810+
'<figure><img src="/aaa/bbb.jpg" alt="foo"><figcaption aria-hidden="true">foo</figcaption></figure></p>\n'
811811
].join('\n'));
812812
});
813813

0 commit comments

Comments
 (0)