771333c1d5e542f6f545265db6a834cc228aee17 — Case Duckworth 4 months ago 12918b5
Add striptagsField
1 files changed, 9 insertions(+), 0 deletions(-)

M src/Acdw/Contexts.hs
M src/Acdw/Contexts.hs => src/Acdw/Contexts.hs +9 -0
@@ 21,6 21,7 @@ baseCtx =
     [ canonicalField "canonical"
     , metaKeywordField "keywords"
     , constField "root" canonical
+    , stripTagsField "striptags"
     , defaultContext
     ]
 


@@ 81,3 82,11 @@ replyHrefField key =
     let subject = fromMaybe "" t
     return $
       mconcat ["mailto:", address, "@comments.acdw.net?subject=", subject]
+
+-- | strip the tags from a field
+stripTagsField :: String -> Context a
+stripTagsField key =
+  functionField key $ \args ->
+    case args of
+      [k] -> return $ return $ stripTags k
+      _   -> fail "stripTagsField: takes 1 argument"