diff --git a/ghost/importer-revue/lib/importer-revue.js b/ghost/importer-revue/lib/importer-revue.js index bf1f3fb549..fa98c2ca48 100644 --- a/ghost/importer-revue/lib/importer-revue.js +++ b/ghost/importer-revue/lib/importer-revue.js @@ -33,14 +33,14 @@ const fetchPostsFromData = (revueData) => { } const revuePostID = postMeta.id; - let postHTML = postMeta.description; + let postHTML = JSONToHTML.cleanCsvHTML(postMeta.description); const postItems = _.filter(itemData, {issue_id: revuePostID}); const sortedPostItems = _.sortBy(postItems, o => o.order); if (postItems) { const convertedItems = JSONToHTML.itemsToHtml(sortedPostItems); - postHTML = `${postMeta.description}${convertedItems}`; + postHTML = `${postHTML}${convertedItems}`; } const postDate = JSONToHTML.getPostDate(postMeta); @@ -54,9 +54,7 @@ const fetchPostsFromData = (revueData) => { created_at: postDate, published_at: postDate, updated_at: postDate, - html: postHTML, - tags: ['#revue'] - + html: postHTML }); }); diff --git a/ghost/importer-revue/lib/json-to-html.js b/ghost/importer-revue/lib/json-to-html.js index 2c5b8fbac3..cc126323ac 100644 --- a/ghost/importer-revue/lib/json-to-html.js +++ b/ghost/importer-revue/lib/json-to-html.js @@ -88,8 +88,20 @@ const getPostStatus = (data) => { return (isPublished) ? 'published' : 'draft'; }; +const cleanCsvHTML = (data) => { + // Blockquotes need to have some sort of wrapping elements around all contents + // Wrap all content in
tags. The HTML to Mobiledoc parse can handle duplicate
tags. + data = data.replace(/
'); + + // These exports have a lot of$1
<\/p>/gm, '');
+
+ return data;
+};
+
module.exports = {
itemsToHtml,
getPostDate,
- getPostStatus
+ getPostStatus,
+ cleanCsvHTML
};
diff --git a/ghost/importer-revue/test/importer-revue.test.js b/ghost/importer-revue/test/importer-revue.test.js
index b37363b689..169d868bd0 100644
--- a/ghost/importer-revue/test/importer-revue.test.js
+++ b/ghost/importer-revue/test/importer-revue.test.js
@@ -68,8 +68,7 @@ describe('Revue Importer', function () {
created_at: '2022-12-01T01:01:30.000Z',
published_at: '2022-12-01T01:01:30.000Z',
updated_at: '2022-12-01T01:01:30.000Z',
- html: '
Hello World!
', - tags: ['#revue'] + html: 'Hello World!
' } ]); }); @@ -88,9 +87,6 @@ describe('Revue Importer', function () { html: 'Hello World!
Goodbye World!
', published_at: '2022-12-01T01:01:30.000Z', status: 'published', - tags: [ - '#revue' - ], title: 'Hello World - Issue #8', slug: 'hello-world-issue-8', updated_at: '2022-12-01T01:01:30.000Z', @@ -113,8 +109,7 @@ describe('Revue Importer', function () { created_at: '2022-12-01T01:02:03.123Z', published_at: '2022-12-01T01:02:03.123Z', updated_at: '2022-12-01T01:02:03.123Z', - html: 'Hello World!
Goodbye World!
', - tags: ['#revue'] + html: 'Hello World!
Goodbye World!
' } ]); }); @@ -223,5 +218,19 @@ describe('Revue Importer', function () { assert.deepEqual(result, ''); }); }); + + describe('cleanCsvHTML', function () { + it('can wrap blockquote content in p tags', function () { + const result = JSONToHTML.cleanCsvHTML('Hello World!
Try This!'); + + assert.deepEqual(result, '
Hello World!
'); + }); + + it('can remove unwanted blank paragraphs', function () { + const result = JSONToHTML.cleanCsvHTML('Try This!
Hello World!
Goodbye World!
'); + + assert.deepEqual(result, 'Hello World!
Goodbye World!
'); + }); + }); }); });