From 34e3154c7ae1b002ff85cd0837c3cbf7d672d458 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 27 Nov 2023 13:55:04 +0100 Subject: close separate-database-issues-and-history-issues --- app/Issue/Text.hs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'app/Issue') diff --git a/app/Issue/Text.hs b/app/Issue/Text.hs index 7c81c91..5d1dddb 100644 --- a/app/Issue/Text.hs +++ b/app/Issue/Text.hs @@ -1,6 +1,11 @@ -module Issue.Text (extractText) where +module Issue.Text + ( extractText, + stripIssueMarkers, + issueMarkers, + ) +where -import Control.Arrow (second) +import Control.Arrow (first, second) import Data.List (find) import Data.Maybe (fromMaybe) import Data.Text (Text) @@ -46,3 +51,19 @@ stripBlockComment blockStart blockEnd text = . (fromMaybe text . T.stripSuffix blockEnd) . (fromMaybe text . T.stripPrefix blockStart) $ text + +issueMarkers :: [T.Text] +issueMarkers = + [ "TODO", + "FIXME", + "QUESTION" + ] + +stripIssueMarkers :: T.Text -> ([T.Text], T.Text) +stripIssueMarkers text = + case [marker | marker <- issueMarkers, T.isPrefixOf marker text] of + (marker : _) -> + first (marker :) . stripIssueMarkers $ + T.stripStart (T.drop (T.length marker) text) + [] -> + ([], text) -- cgit v1.2.3