From cfeca542e6827f2ae44f55a3c35a4b94d1f34c6a Mon Sep 17 00:00:00 2001 From: Rajarshee Chatterjee Date: Sat, 12 Jun 2021 11:08:28 +0530 Subject: [PATCH] Woopread: Remove links --- src/en/woopread/WoopReadScraper.js | 6 ++++-- src/helper.js | 6 +----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/en/woopread/WoopReadScraper.js b/src/en/woopread/WoopReadScraper.js index 546842b..f9c5cc7 100644 --- a/src/en/woopread/WoopReadScraper.js +++ b/src/en/woopread/WoopReadScraper.js @@ -139,8 +139,10 @@ const chapterScraper = async (req, res) => { const chapterName = $("h1#chapter-heading").text(); let chapterText = $(".reading-content").html(); - chapterText = parseHtml(chapterText); - chapterText = chapterText.replace(/(?<=[[])[\n](?=[h])/g, ""); + chapterText = parseHtml(chapterText).replace( + /\[(https:\/\/docs.google.com\/)(.*?)\]/g, + "" + ); let nextChapter = null; diff --git a/src/helper.js b/src/helper.js index 5bed3ba..ae4e2e7 100644 --- a/src/helper.js +++ b/src/helper.js @@ -28,11 +28,7 @@ const scraper = async (url) => { const parseHtml = (html) => { let text = htmlToText(html); - text = text.replace( - /(?<=[ A-Za-z0-9_@./#&+-])\n(?=[ A-Za-z0-9_@./#&+-])/g, - " " - ); - + text = text.replace(/\n{2,}/g, "\n\n"); return text; };