diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-11-09 15:35:32 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-11-09 15:36:16 +0100 |
commit | f0675acff032a2558d0d7b303c0b8199fd17c162 (patch) | |
tree | 4ea5cd68bb7155d132befe48132c0af4bf6be10b /app | |
parent | 075afbe4d365d8056a610d6e05d699893337c064 (diff) |
fix extracting tags from code
Diffstat (limited to 'app')
-rw-r--r-- | app/Issue/Tag.hs | 35 | ||||
-rw-r--r-- | app/Main.hs | 9 |
2 files changed, 22 insertions, 22 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 = diff --git a/app/Main.hs b/app/Main.hs index 1aff48b..e1ae560 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -38,7 +38,6 @@ -- I am neither for nor against replacing `mdcat` with our own markdown -- rendering. -- --- @supersedes exclude-tags-in-code-blocks -- @supersedes make-show-page-able -- @supersedes only-separate-generated-tags-with-a-blank-line-when-description-does-not-end-with-tags -- @@ -175,14 +174,6 @@ -- @should-automatically-generated-ids-be-random, as long as they are an -- additional mechanisam (so that we can ditch them, should they not work out). --- FIXME Exclude tags in code blocks --- --- Tags which appear in markdown code blocks should not be considered --- tags. --- --- @topic tags --- @topic markdown - -- TODO Only separate generated tags with a blank line when description does not end with tags -- -- An issue like |