Skip to content

Commit e71bb9b

Browse files
committed
mg-squarespace: Better handling of blockquotes
1 parent 7fecbd6 commit e71bb9b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

packages/mg-squarespace-xml/lib/process.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ const processContent = (html) => {
6969
}
7070
});
7171

72+
$html('figure blockquote').each((i, el) => {
73+
const nextIsCaption = $(el).next('figcaption').length;
74+
let captionText = '';
75+
if (nextIsCaption) {
76+
captionText = `<br><br>${$(el).next('figcaption').html()}`;
77+
$(el).next('figcaption').remove();
78+
}
79+
$(el).html(`<p>${$(el).html()}${captionText}</p>`);
80+
});
81+
7282
// TODO: this should be a parser plugin
7383
// Wrap nested lists in HTML card
7484
$html('ul li ul, ol li ol, ol li ul, ul li ol').each((i, nestedList) => {

packages/mg-squarespace-xml/test/process.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,27 @@ describe('Process', function () {
248248
expect(processed).not.toContain('<div class="sqs-audio-embed"');
249249
});
250250

251+
test('Can convert blockquotes', async function () {
252+
let blockquote = `<p>Hello</p>
253+
<figure class="block-animation-none">
254+
<blockquote data-animation-role="quote">
255+
<span>“</span>Lorem ipsum<br><br>dolor simet.<span>”</span>
256+
</blockquote>
257+
<figcaption class="source">— Lipsum</figcaption>
258+
</figure>
259+
<p>World</p>`;
260+
261+
let processed = process.processContent(blockquote);
262+
263+
expect(processed).toEqual('<p>Hello</p>\n' +
264+
'<figure class="block-animation-none">\n' +
265+
' <blockquote data-animation-role="quote"><p>\n' +
266+
' <span>“</span>Lorem ipsum<br><br>dolor simet.<span>”</span>\n' +
267+
' <br><br>— Lipsum</p></blockquote>\n' +
268+
' \n' +
269+
'</figure>\n' +
270+
'<p>World</p>'); });
271+
251272
test('Can handle posts with no title', async function () {
252273
let ctx = {
253274
options: {

0 commit comments

Comments
 (0)