23 lines
528 B
Haskell
Executable file
23 lines
528 B
Haskell
Executable file
#!/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
|
|
|