mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
Removed leading/trailing HR's when rendering email content
refs https://github.com/TryGhost/Team/issues/1007 - the new `email-cta` card allows surrounding dividers to be added when rendering, however if the card is at the beginning or end of the post then these would double-up with the already existing dividers at the beginning and end of the post content in the email template - not wanting leading/trailing HR's is specific to the email template so it made sense to adjust the renderer output in Ghost's email generating rather than forcing all mobiledoc->html rendering to remove leading/trailing HR's
This commit is contained in:
parent
5e83d87ab9
commit
946ae43a15
@ -218,6 +218,14 @@ const serialize = async (postModel, options = {isBrowserPreview: false, apiVersi
|
||||
}
|
||||
|
||||
post.html = mobiledocLib.mobiledocHtmlRenderer.render(JSON.parse(post.mobiledoc), {target: 'email'});
|
||||
|
||||
// perform any email specific adjustments to the mobiledoc->HTML render output
|
||||
let _cheerio = cheerio.load(post.html);
|
||||
// remove leading/trailing HRs
|
||||
_cheerio(':root > hr:first-child, :root > div:first-child > hr:first-child').remove();
|
||||
_cheerio(':root > hr:last-child, :root > div:last-child > hr:last-child').remove();
|
||||
post.html = _cheerio.html();
|
||||
|
||||
post.plaintext = htmlToPlaintext(post.html);
|
||||
|
||||
// Outlook will render feature images at full-size breaking the layout.
|
||||
@ -268,7 +276,7 @@ const serialize = async (postModel, options = {isBrowserPreview: false, apiVersi
|
||||
|
||||
// convert juiced HTML to a DOM-like interface for further manipulation
|
||||
// happens after inlining of CSS so we can change element types without worrying about styling
|
||||
let _cheerio = cheerio.load(juicedHtml);
|
||||
_cheerio = cheerio.load(juicedHtml);
|
||||
// force all links to open in new tab
|
||||
_cheerio('a').attr('target','_blank');
|
||||
// convert figure and figcaption to div so that Outlook applies margins
|
||||
|
Loading…
Reference in New Issue
Block a user