taggy-0.1.1: Efficient and simple HTML/XML parsing library

Stabilityexperimental
Maintaineralpmestan@gmail.com
Safe HaskellSafe-Inferred

Text.Taggy.Types

Contents

Description

Core types of taggy.

Synopsis

Tag type

data Tag Source

A Tag can be one of the following types of tags:

  • an opening tag that has a name, a list of attributes, and whether it is a self-closing tag or not * a closing tag with the name of the tag * some raw Text * an HTML comment tag * a script.../script tag * a style.../style tag

The latter two are useful to be considered separately in the parser and also lets you collect these bits quite easily.

Instances

tname :: Tag -> TextSource

Name of a Tag.

 tname (TagClose "a") == "a"

isTagOpen :: Tag -> BoolSource

Is this Tag an opening tag?

isTagClose :: Tag -> BoolSource

Is this Tag a closing tag?

isTagText :: Tag -> BoolSource

Is this Tag just some flat text?

isTagComment :: Tag -> BoolSource

Is this Tag an HTML comment tag?

isTagScript :: Tag -> BoolSource

Is this Tag a script.../script tag?

isTagStyle :: Tag -> BoolSource

Is this Tag a style.../style tag?

tagsNamed :: Text -> [Tag] -> [Tag]Source

Get all the (opening) tags with the given name

Attributes

data Attribute Source

An attribute is just an attribute name and an attribute value.

Constructors

Attribute !Text !Text 

attrs :: Tag -> [Attribute]Source

Get the attributes of a Tag.

attrKey :: Attribute -> TextSource

Get the name of an Attribute.

attrValue :: Attribute -> TextSource

Get the value of an Attribute.

A small difference list implementation

data L a Source

appL :: L a -> L a -> L aSource

insertL :: a -> L a -> L aSource

toListL :: L a -> [a]Source