Skip to content

Commit

Permalink
mg-squarespace: Better handling of blockquotes
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulAdamDavis committed Mar 10, 2025
1 parent 7fecbd6 commit e71bb9b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/mg-squarespace-xml/lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ const processContent = (html) => {
}
});

$html('figure blockquote').each((i, el) => {
const nextIsCaption = $(el).next('figcaption').length;
let captionText = '';
if (nextIsCaption) {
captionText = `<br><br>${$(el).next('figcaption').html()}`;
$(el).next('figcaption').remove();
}
$(el).html(`<p>${$(el).html()}${captionText}</p>`);
});

// TODO: this should be a parser plugin
// Wrap nested lists in HTML card
$html('ul li ul, ol li ol, ol li ul, ul li ol').each((i, nestedList) => {
Expand Down
21 changes: 21 additions & 0 deletions packages/mg-squarespace-xml/test/process.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,27 @@ describe('Process', function () {
expect(processed).not.toContain('<div class="sqs-audio-embed"');
});

test('Can convert blockquotes', async function () {
let blockquote = `<p>Hello</p>
<figure class="block-animation-none">
<blockquote data-animation-role="quote">
<span>“</span>Lorem ipsum<br><br>dolor simet.<span>”</span>
</blockquote>
<figcaption class="source">— Lipsum</figcaption>
</figure>
<p>World</p>`;

let processed = process.processContent(blockquote);

expect(processed).toEqual('<p>Hello</p>\n' +
'<figure class="block-animation-none">\n' +
' <blockquote data-animation-role="quote"><p>\n' +
' <span>“</span>Lorem ipsum<br><br>dolor simet.<span>”</span>\n' +
' <br><br>— Lipsum</p></blockquote>\n' +
' \n' +
'</figure>\n' +
'<p>World</p>'); });

test('Can handle posts with no title', async function () {
let ctx = {
options: {
Expand Down

0 comments on commit e71bb9b

Please sign in to comment.