mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
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:
parent
75cc60c20a
commit
0c06a47b9b
4 changed files with 6 additions and 6 deletions
|
@ -16,7 +16,7 @@ module.exports = {
|
||||||
|
|
||||||
if (payload.caption) {
|
if (payload.caption) {
|
||||||
let figcaption = dom.createElement('figcaption');
|
let figcaption = dom.createElement('figcaption');
|
||||||
figcaption.appendChild(dom.createTextNode(payload.caption));
|
figcaption.appendChild(dom.createRawHTMLSection(payload.caption));
|
||||||
figure.appendChild(figcaption);
|
figure.appendChild(figcaption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ module.exports = {
|
||||||
|
|
||||||
if (payload.caption) {
|
if (payload.caption) {
|
||||||
let figcaption = dom.createElement('figcaption');
|
let figcaption = dom.createElement('figcaption');
|
||||||
figcaption.appendChild(dom.createTextNode(payload.caption));
|
figcaption.appendChild(dom.createRawHTMLSection(payload.caption));
|
||||||
figure.appendChild(figcaption);
|
figure.appendChild(figcaption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,10 @@ describe('Embed card', function () {
|
||||||
},
|
},
|
||||||
payload: {
|
payload: {
|
||||||
html: 'Testing',
|
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>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,11 +24,11 @@ describe('Image card', function () {
|
||||||
},
|
},
|
||||||
payload: {
|
payload: {
|
||||||
src: 'https://www.ghost.org/image.png',
|
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 () {
|
it('renders an image with alt text', function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue