diff --git a/lib/routes/facebook/page.js b/lib/routes/facebook/page.js index b865228e7..1a994a9ac 100644 --- a/lib/routes/facebook/page.js +++ b/lib/routes/facebook/page.js @@ -33,18 +33,7 @@ const parseStoryPage = async (linkPath, cache) => { const isAttachAreImageSet = attachLinkList.filter((link) => new RegExp('/photos/').test(link)).length === attachLinkList.length; const title = $header.find('h3').text(); - let content = ''; - if ($content.find('p').length === 0) { - $content.find('br').replaceWith('\n'); - content = $content.text(); - } else { - const $ps = $content.find('p'); - $ps.find('br').replaceWith('\n'); - content = $ps - .toArray() - .map((p) => $(p).text()) - .join('\n'); - } + const content = $content.html(); let images = []; if (isAttachAreImageSet) { @@ -69,8 +58,7 @@ const parsePhotoPage = async (linkPath, cache) => { const title = $('#MPhotoContent div.msg > a > strong').first().text(); const url = `https://www.facebook.com${pathname}`; const $content = $('#MPhotoContent div.msg > div'); - $content.find('br').replaceWith('\n'); - const content = $content.text(); + const content = $content.html(); const image = $('#MPhotoContent div.desc.attachment > span > div > span > a[target=_blank].sec').attr('href'); return { @@ -100,7 +88,7 @@ module.exports = async (ctx) => { return { title: data.title, link: data.url, - description: `
${data.content.replace(/\n/g, '
')}`, + description: `
${data.content}`, }; } if (new RegExp(`^/story.php`).test(itemLink)) { @@ -109,10 +97,10 @@ module.exports = async (ctx) => { const isEmptyImageList = data.images.length === 0; let desc = ''; - desc += data.images.map((image) => `
${image.content.replace(/\n/g, '
')}`).join('
'); + desc += data.images.map((image) => `
${image.content}`).join('
'); if (!isSingleImageStory) { !isEmptyImageList && (desc += '
'); - desc += data.content.replace(/\n/g, '
'); + desc += data.content; } return {