diff options
Diffstat (limited to 'app/Issue')
-rw-r--r-- | app/Issue/Tag.hs | 35 |
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 = |