Koenig - Added rich-text caption support

refs https://github.com/TryGhost/Ghost/issues/9724
- captions can have HTML so we need to render as HTML rather than as a text node so special chars don't get escaped
This commit is contained in:
Kevin Ansfield 2018-08-08 14:29:20 +01:00
parent 75cc60c20a
commit 0c06a47b9b
4 changed files with 6 additions and 6 deletions

View File

@ -16,7 +16,7 @@ module.exports = {
if (payload.caption) {
let figcaption = dom.createElement('figcaption');
figcaption.appendChild(dom.createTextNode(payload.caption));
figcaption.appendChild(dom.createRawHTMLSection(payload.caption));
figure.appendChild(figcaption);
}

View File

@ -28,7 +28,7 @@ module.exports = {
if (payload.caption) {
let figcaption = dom.createElement('figcaption');
figcaption.appendChild(dom.createTextNode(payload.caption));
figcaption.appendChild(dom.createRawHTMLSection(payload.caption));
figure.appendChild(figcaption);
}

View File

@ -63,10 +63,10 @@ describe('Embed card', function () {
},
payload: {
html: 'Testing',
caption: 'Caption'
caption: '<strong>Caption</strong>'
}
};
serializer.serialize(card.render(opts)).should.match('<figure class="kg-embed-card">Testing<figcaption>Caption</figcaption></figure>');
serializer.serialize(card.render(opts)).should.match('<figure class="kg-embed-card">Testing<figcaption><strong>Caption</strong></figcaption></figure>');
});
});

View File

@ -24,11 +24,11 @@ describe('Image card', function () {
},
payload: {
src: 'https://www.ghost.org/image.png',
caption: 'Test caption'
caption: '<b>Test caption</b>'
}
};
serializer.serialize(card.render(opts)).should.eql('<figure class="kg-image-card"><img src="https://www.ghost.org/image.png" class="kg-image"><figcaption>Test caption</figcaption></figure>');
serializer.serialize(card.render(opts)).should.eql('<figure class="kg-image-card"><img src="https://www.ghost.org/image.png" class="kg-image"><figcaption><b>Test caption</b></figcaption></figure>');
});
it('renders an image with alt text', function () {