@@ -207,6 +207,8 @@ ignoreBlank = ignoreElem test
207 | otherwise -> False
207 | otherwise -> False
209-- | Returns name of current element.
209-- | Returns name of current element.
210getCurrentName :: (Monad m) => DomParserT Identity m Text
212getCurrentName :: (Monad m) => DomParserT Identity m Text
211getCurrentName = view $ pdElements . to runIdentity . localName
213getCurrentName = view $ pdElements . to runIdentity . localName
@@ -227,6 +229,8 @@ checkCurrentName n = do
228-- | Get current content. If current element contains no content or
230-- | Get current content. If current element contains no content or
229-- have inner elements then Nothing returned
231-- have inner elements then Nothing returned
230getCurrentContent :: (Monad m) => DomParserT Identity m (Maybe Text)
234getCurrentContent :: (Monad m) => DomParserT Identity m (Maybe Text)
231getCurrentContent = do
235getCurrentContent = do
232 nds <- view $ pdElements . to runIdentity . nodes
236 nds <- view $ pdElements . to runIdentity . nodes
@@ -254,6 +258,10 @@ parseContent parse = getCurrentContent >>= \case
254 Left e -> throwParserError $ PEWrongFormat e
258 Left e -> throwParserError $ PEWrongFormat e
255 Right a -> return a
259 Right a -> return a
261+-- | If reader returns 'Nothing' then resulting function returns 'Left
257maybeReadContent
265maybeReadContent
258 :: forall a
266 :: forall a
259 . (Typeable a)
267 . (Typeable a)
@@ -275,9 +283,15 @@ readContent
275 -> Either Text a
283 -> Either Text a
276readContent = maybeReadContent $ readMaybe . T.unpack . T.strip
284readContent = maybeReadContent $ readMaybe . T.unpack . T.strip
286+-- | Retuns map of attributes of current element
278getCurrentAttributes :: (Monad m) => DomParserT Identity m (M.Map Name Text)
289getCurrentAttributes :: (Monad m) => DomParserT Identity m (M.Map Name Text)
279getCurrentAttributes = view $ pdElements . to runIdentity . attrs
290getCurrentAttributes = view $ pdElements . to runIdentity . attrs
292+-- | Returns element with given name or 'Nothing'
281getCurrentAttribute :: (Monad m) => Text -> DomParserT Identity m (Maybe Text)
295getCurrentAttribute :: (Monad m) => Text -> DomParserT Identity m (Maybe Text)
282getCurrentAttribute attrName'
296getCurrentAttribute attrName'
283 = preview $ pdElements . to runIdentity . attr attrName
297 = preview $ pdElements . to runIdentity . attr attrName
@@ -285,6 +299,8 @@ getCurrentAttribute attrName'
285 attrName = Name attrName' Nothing Nothing
299 attrName = Name attrName' Nothing Nothing
287-- | Parses attribute with given name, throws error if attribute is not found.
301-- | Parses attribute with given name, throws error if attribute is not found.
288parseAttribute
304parseAttribute
289 :: (Monad m)
305 :: (Monad m)