diff --git a/ghost/core/core/server/data/importer/importers/data/posts.js b/ghost/core/core/server/data/importer/importers/data/posts.js index 76f4a30b53..b6cc4c2c19 100644 --- a/ghost/core/core/server/data/importer/importers/data/posts.js +++ b/ghost/core/core/server/data/importer/importers/data/posts.js @@ -272,7 +272,11 @@ class PostsImporter extends BaseImporter { model.mobiledoc = JSON.stringify(mobiledoc); model.html = mobiledocLib.mobiledocHtmlRenderer.render(JSON.parse(model.mobiledoc)); + } else if (model.html) { + model.mobiledoc = JSON.stringify(mobiledocLib.htmlToMobiledocConverter(model.html)); + model.html = mobiledocLib.mobiledocHtmlRenderer.render(JSON.parse(model.mobiledoc)); } + this.sanitizePostsMeta(model); }); diff --git a/ghost/core/test/integration/importer/v1.test.js b/ghost/core/test/integration/importer/v1.test.js index c71109a69a..b10fa5a1ea 100644 --- a/ghost/core/test/integration/importer/v1.test.js +++ b/ghost/core/test/integration/importer/v1.test.js @@ -74,7 +74,7 @@ describe('Importer 1.0', function () { }); }); - it('mobiledoc is null, html field is set', function () { + it('mobiledoc is null, html field is set, convert html -> mobiledoc', function () { const exportData = exportedBodyV1().db[0]; exportData.data.posts[0] = testUtils.DataGenerator.forKnex.createPost({ @@ -95,8 +95,8 @@ describe('Importer 1.0', function () { const posts = result[0].data.map(model => model.toJSON(options)); posts.length.should.eql(1); - should(posts[0].html).eql(null); - posts[0].mobiledoc.should.eql('{"version":"0.3.1","ghostVersion":"4.0","markups":[],"atoms":[],"cards":[],"sections":[[1,"p",[[0,[],0,""]]]]}'); + should(posts[0].html).eql('

This is my post content.

'); + posts[0].mobiledoc.should.eql('{"version":"0.3.1","atoms":[],"cards":[],"markups":[],"sections":[[1,"h1",[[0,[],0,"This is my post content."]]]]}'); }); });