aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue/Text.hs
blob: e61cbd42086fceda072339adc286eaa18b9658bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Issue.Text
  ( stripIssueMarkers,
    issueMarkers,
  )
where

import Control.Arrow (first)
import Data.Text qualified as T

issueMarkers :: [T.Text]
issueMarkers =
  [ "FIXME",
    "QUESTION",
    "TODO",
    "XXX"
  ]

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)