seonbi-0.4.0: SmartyPants for Korean language
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Seonbi.Html.Wrapper

Synopsis

Documentation

isWrappedBy :: [HtmlEntity] -> HtmlTag -> Bool Source #

A shortcut to isWrappedBy' of wildcard attributes match.

isWrappedBy' :: [HtmlEntity] -> HtmlTag -> Maybe HtmlRawAttrs -> Bool Source #

True if the given [HtmlEntity] is wrapped by a tag and attributes. E.g.:

>>> :set -XOverloadedLists
>>> :set -XOverloadedStrings
>>> :{
let entities = 
        [ HtmlStartTag [] Em " id=foo"
        , HtmlText [Em] "Hello"
        , HtmlEndTag [] Em
        ] :: [HtmlEntity]
:}
>>> isWrappedBy' entities Em $ Just " id=foo"
True
>>> isWrappedBy' entities Div $ Just " id=foo"
False
>>> isWrappedBy' entities Em $ Just " id=wrong"
False

In order to match to any attributes (wildcard match), give Nothing to the third argument:

>>> isWrappedBy' entities Em Nothing
True
>>> isWrappedBy' entities Span Nothing
False

Or you can use isWrappedBy function which is a shortcut for that.

wrap :: HtmlTagStack -> HtmlTag -> HtmlRawAttrs -> [HtmlEntity] -> [HtmlEntity] Source #

Wraps given entities with an element.