docmachine-containers/utils/docs/filter-nobg.hs

24 lines
528 B
Haskell
Raw Normal View History

2024-12-11 22:14:25 +01:00
#!/usr/bin/env runhaskell
{-# LANGUAGE OverloadedStrings #-}
import Text.Pandoc.JSON
import Data.Text (Text, isInfixOf)
-- Function to filter out images with 'bg' in alt text
filterImage :: Inline -> Inline
filterImage img@(Image attr alt _) =
if any ("bg" `isInfixOf`) (map stringify alt)
then Str ""
else img
filterImage x = x
-- Stringify function to convert inlines to Text
stringify :: Inline -> Text
stringify (Str txt) = txt
stringify _ = ""
-- Main function
main :: IO ()
main = toJSONFilter filterImage