From 09d5a5941a1feb23aece4d5311092c1a23d4ae11 Mon Sep 17 00:00:00 2001 From: Fabian Kirchner Date: Fri, 13 Oct 2023 20:45:00 +0200 Subject: also support FIXME and QUESTION as markers --- app/Issue.hs | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'app/Issue.hs') diff --git a/app/Issue.hs b/app/Issue.hs index a222d0a..ab47ba5 100644 --- a/app/Issue.hs +++ b/app/Issue.hs @@ -5,7 +5,7 @@ module Issue (Issue (..), fromMatch, id) where -import Data.List (find) +import Data.List (find, foldl') import Data.Text (Text) import Data.Text qualified as T import Issue.Tag (Tag (..)) @@ -37,7 +37,7 @@ id issue = fromMatch :: G.Result -> G.Match -> Maybe Issue fromMatch result match = - if T.isPrefixOf marker title' + if any (\marker -> T.isPrefixOf marker title') issueMarkers then Just Issue @@ -52,10 +52,19 @@ fromMatch result match = else Nothing where (title', description) = I.extractText result.file_type match.text - title = stripMarker title' + title = stripIssueMarkers title' -marker :: Text -marker = "TODO" +issueMarkers :: [Text] +issueMarkers = + [ "TODO", + "FIXME", + "QUESTION" + ] -stripMarker :: Text -> Text -stripMarker text = maybe text T.stripStart (T.stripPrefix marker text) +stripIssueMarkers :: Text -> Text +stripIssueMarkers text = + foldl' (stripIssueMarker) text issueMarkers + +stripIssueMarker :: Text -> Text -> Text +stripIssueMarker text marker = + maybe text T.stripStart (T.stripPrefix marker text) -- cgit v1.2.3