From fd5850c862b4093742f5d3155c9f161038322ca7 Mon Sep 17 00:00:00 2001 From: natyusha <985941+natyusha@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:30:21 -0400 Subject: [PATCH] =?UTF-8?q?Remove=20"=E2=80=94=20written=20by"=20/=20"*=20?= =?UTF-8?q?Based=20on"=20Lines=20and=20Leftover=20BBCode=20From=20Series?= =?UTF-8?q?=20Descriptions=20(#1027)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove "— written by" Lines From Series Descriptions * Remove Leftover BBCode - Remove anything inside BBCode [i] tags * Remove "* Based On" Section - add it to the written by const and rename --- src/components/Collection/CleanDescription.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Collection/CleanDescription.tsx b/src/components/Collection/CleanDescription.tsx index 8ea4dffae..012d4deef 100644 --- a/src/components/Collection/CleanDescription.tsx +++ b/src/components/Collection/CleanDescription.tsx @@ -3,9 +3,13 @@ import React, { useMemo } from 'react'; // The question marks are there because people can't spell… const RemoveSummaryRegex = /\b(Sour?ce|Note|Summ?ary):([^\r\n]+|$)/mg; +const RemoveBasedOnWrittenByRegex = /^(\*|\u2014) ([^\r\n]+|$)/mg; + +const RemoveBBCodeRegex = /\[i\].*\[\/i\]/sg; + const MultiSpacesRegex = /\s{2,}/g; -const CleanMiscLinesRegex = /^(\*|--|~) /sg; +const CleanMiscLinesRegex = /^(--|~) /sg; const CleanMultiEmptyLinesRegex = /\n{2,}/sg; @@ -18,6 +22,8 @@ const CleanDescription = React.memo(({ className, text }: { text: string, classN const cleanedText = text .replaceAll(CleanMiscLinesRegex, '') .replaceAll(RemoveSummaryRegex, '') + .replaceAll(RemoveBasedOnWrittenByRegex, '') + .replaceAll(RemoveBBCodeRegex, '') .replaceAll(CleanMultiEmptyLinesRegex, '\n') .replaceAll(MultiSpacesRegex, ' ');