aboutsummaryrefslogtreecommitdiffstats
path: root/app/Issue
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-09 15:35:32 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-11-09 15:36:16 +0100
commitf0675acff032a2558d0d7b303c0b8199fd17c162 (patch)
tree4ea5cd68bb7155d132befe48132c0af4bf6be10b /app/Issue
parent075afbe4d365d8056a610d6e05d699893337c064 (diff)
fix extracting tags from code
Diffstat (limited to 'app/Issue')
-rw-r--r--app/Issue/Tag.hs35
1 files changed, 22 insertions, 13 deletions
diff --git a/app/Issue/Tag.hs b/app/Issue/Tag.hs
index 2f584b3..29c69d9 100644
--- a/app/Issue/Tag.hs
+++ b/app/Issue/Tag.hs
@@ -8,6 +8,7 @@ module Issue.Tag
)
where
+import CMark qualified as D
import Data.Binary (Binary)
import Data.Maybe (catMaybes, mapMaybe)
import Data.Text (Text, pack)
@@ -34,19 +35,27 @@ tagValuesOf key =
)
extractTags :: Text -> [Tag]
-extractTags =
- catMaybes
- . map
- ( ( \case
- ((T.uncons -> Just ('@', k)) : v) ->
- case T.strip (T.unwords v) of
- "" -> Just (Tag k Nothing)
- v' -> Just (Tag k (Just v'))
- _ -> Nothing
- )
- . T.words
- )
- . T.lines
+extractTags = collect . D.commonmarkToNode []
+ where
+ collect (D.Node _ (D.CODE _) _) = []
+ collect (D.Node _ (D.CODE_BLOCK _ _) _) = []
+ collect (D.Node _ (D.TEXT s) ns) = extract s ++ concatMap collect ns
+ collect (D.Node _ _ []) = []
+ collect (D.Node _ _ ns) = concatMap collect ns
+
+ extract =
+ catMaybes
+ . map
+ ( ( \case
+ ((T.uncons -> Just ('@', k)) : v) ->
+ case T.strip (T.unwords v) of
+ "" -> Just (Tag k Nothing)
+ v' -> Just (Tag k (Just v'))
+ _ -> Nothing
+ )
+ . T.words
+ )
+ . T.lines
internalTags :: Text -> Maybe Provenance -> [T.Text] -> [Tag]
internalTags title provenance' markers =