diff options
Diffstat (limited to 'app/Issue/Text.hs')
-rw-r--r-- | app/Issue/Text.hs | 25 |
1 files changed, 23 insertions, 2 deletions
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) |