blob: 4cfc5f70ba98f8baf40a14322fc596c1177e0532 (
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
26
27
28
29
30
31
32
33
34
|
module Issue.Text
( extractText,
stripIssueMarkers,
issueMarkers,
)
where
import Control.Arrow (first, second)
import Data.Text (Text)
import Data.Text qualified as T
extractText :: Text -> (Text, Maybe Text)
extractText text = (title, description)
where
(title, description') = second T.stripStart $ T.breakOn "\n" text
description
| T.null description' = Nothing
| otherwise = Just description'
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)
|