mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Added consistent handling to empty mobiledoc
closes #10612 - Added handling for 'blank' mobiledoc structure which should be converted to '""' instead of '<p></p>'
This commit is contained in:
parent
04857e8823
commit
2517e9dc65
2 changed files with 32 additions and 1 deletions
|
@ -108,7 +108,8 @@ module.exports = {
|
|||
// Koenig keeps a blank paragraph at the end of a doc but we want to
|
||||
// make sure it doesn't get rendered
|
||||
let lastChild = rendered.result.lastChild;
|
||||
if (lastChild && lastChild.tagName === 'P' && !lastChild.firstChild) {
|
||||
if (lastChild && lastChild.tagName === 'P'
|
||||
&& !(lastChild.firstChild && lastChild.firstChild.nodeValue)) {
|
||||
rendered.result.removeChild(lastChild);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,36 @@ describe('Mobiledoc converter', function () {
|
|||
converter.render(mobiledoc, 2).should.eql('<p>Test</p>');
|
||||
});
|
||||
|
||||
it('removes single blank paragraph', function () {
|
||||
let mobiledoc = {
|
||||
version: '0.3.1',
|
||||
atoms: [],
|
||||
cards: [],
|
||||
markups: [],
|
||||
sections: [
|
||||
[1, 'p', []]
|
||||
]
|
||||
};
|
||||
|
||||
converter.render(mobiledoc, 2).should.eql('');
|
||||
});
|
||||
|
||||
it('removes single blank paragraph with empty content', function () {
|
||||
let mobiledoc = {
|
||||
version: '0.3.1',
|
||||
markups: [],
|
||||
atoms: [],
|
||||
cards: [],
|
||||
sections: [
|
||||
[1, 'p', [
|
||||
[0, [], 0, '']
|
||||
]]
|
||||
]
|
||||
};
|
||||
|
||||
converter.render(mobiledoc, 2).should.eql('');
|
||||
});
|
||||
|
||||
it('adds id attributes to headings', function () {
|
||||
let mobiledoc = {
|
||||
version: '0.3.1',
|
||||
|
|
Loading…
Add table
Reference in a new issue