diff --git a/lib/v2/wsj/utils.js b/lib/v2/wsj/utils.js index 266d61d686..4bf88d0522 100644 --- a/lib/v2/wsj/utils.js +++ b/lib/v2/wsj/utils.js @@ -37,14 +37,29 @@ const parseArticle = (item, ctx) => const article = $('article'); item.subTitle = $('h2.sub-head').html(); - // Remove h1 and h2 - article.find('h1').remove(); - article.find('h2').remove(); - // Remove podcast article.find('.media-object-podcast').remove(); + // Authors + article.find('.bylineWrap').each((i, e) => { + $(e) + .find('p') + .each(function () { + $(this).replaceWith($(this).html()); + }); + }); + // Images + article.find('.bigTop-hero').each((i, e) => { + // console.log($(e).html()); + const imgSrc = $(e).find('amp-img').attr('src'); + const imgAlt = $(e).find('amp-img').attr('alt'); + const figCaption = $(e).find('.imageCaption').text().trim(); + const figCredit = $(e).find('.imageCredit').text().trim(); + const fig = $(`
${imgAlt}
${figCaption} ${figCredit}
`); + $(fig).insertBefore(e); + $(e).remove(); + }); article.find('amp-img').each((i, e) => { const img = $(`${e.attribs.alt}`); @@ -61,7 +76,7 @@ const parseArticle = (item, ctx) => }); // Remove unwanted DOMs - const unwanted_element_selectors = ['amp-ad', '.wsj-ad']; + const unwanted_element_selectors = ['amp-ad', '.wsj-ad', 'h1', 'h2', '.zonedModule', '.snippet', '.newsletter-inset']; unwanted_element_selectors.forEach((selector) => { article.find(selector).each((i, e) => { $(e).remove();