Skip to content

Commit

Permalink
Types.RichText: make blockFindUsernames and blockGetURLs look inside …
Browse files Browse the repository at this point in the history
…tables, as well (fixes #739)
  • Loading branch information
jtdaugherty committed Oct 12, 2021
1 parent e7e7363 commit 5161e1f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/Matterhorn/Types/RichText.hs
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,18 @@ blockFindUsernames (Header _ is) =
inlineFindUsernames $ F.toList $ unInlines is
blockFindUsernames (Blockquote bs) =
findUsernames bs
blockFindUsernames (Table _ header rows) =
let cellFindUsernames = inlineFindUsernames . F.toList . unInlines
in S.unions $
((cellFindUsernames <$> header) <>
(concat $ (fmap cellFindUsernames) <$> rows))
blockFindUsernames (List _ _ bs) =
S.unions $ F.toList $ findUsernames <$> bs
blockFindUsernames _ =
blockFindUsernames HRule =
mempty
blockFindUsernames (HTMLBlock {}) =
mempty
blockFindUsernames (CodeBlock {}) =
mempty

inlineFindUsernames :: [Inline] -> S.Set T.Text
Expand All @@ -467,7 +476,15 @@ blockGetURLs (Blockquote bs) =
blockGetURLs (List _ _ bss) =
mconcat $ mconcat $
(fmap blockGetURLs . F.toList . unBlocks) <$> F.toList bss
blockGetURLs _ =
blockGetURLs (Table _ header rows) =
let cellFindURLs = catMaybes . fmap elementGetURL . F.toList . unInlines
in (concatMap cellFindURLs header) <>
(concatMap (concatMap cellFindURLs) rows)
blockGetURLs HRule =
mempty
blockGetURLs (HTMLBlock {}) =
mempty
blockGetURLs (CodeBlock {}) =
mempty

elementGetURL :: Inline -> Maybe (Either (TeamURLName, PostId) URL, Maybe Inlines)
Expand Down

0 comments on commit 5161e1f

Please sign in to comment.