tagsoupSource codeContentsIndex
Text.HTML.TagSoup.Type
Contents
Data structures and parsing
Position manipulation
Tag identification
Extraction
Description
The central type in TagSoup
Synopsis
class (Typeable a, Eq a) => StringLike a
data Tag str
= TagOpen str [Attribute str]
| TagClose str
| TagText str
| TagComment str
| TagWarning str
| TagPosition !Row !Column
type Attribute str = (str, str)
type Row = Int
type Column = Int
data Position = Position !Row !Column
tagPosition :: Position -> Tag str
nullPosition :: Position
positionChar :: Position -> Char -> Position
positionString :: Position -> String -> Position
isTagOpen :: Tag str -> Bool
isTagClose :: Tag str -> Bool
isTagText :: Tag str -> Bool
isTagWarning :: Tag str -> Bool
isTagPosition :: Tag str -> Bool
isTagOpenName :: Eq str => str -> Tag str -> Bool
isTagCloseName :: Eq str => str -> Tag str -> Bool
fromTagText :: Show str => Tag str -> str
fromAttrib :: (Show str, Eq str, StringLike str) => str -> Tag str -> str
maybeTagText :: Tag str -> Maybe str
maybeTagWarning :: Tag str -> Maybe str
innerText :: StringLike str => [Tag str] -> str
Data structures and parsing
class (Typeable a, Eq a) => StringLike a Source
A class to generalise TagSoup parsing over many types of string-like types. Examples are given for the String type.
show/hide Instances
data Tag str Source
A single HTML element. A whole document is represented by a list of Tag. There is no requirement for TagOpen and TagClose to match.
Constructors
TagOpen str [Attribute str]An open tag with Attributes in their original order
TagClose strA closing tag
TagText strA text node, guaranteed not to be the empty string
TagComment strA comment
TagWarning strMeta: A syntax error in the input file
TagPosition !Row !ColumnMeta: The position of a parsed element
show/hide Instances
Functor Tag
Typeable1 Tag
Eq str => Eq (Tag str)
Data str => Data (Tag str)
Ord str => Ord (Tag str)
Show str => Show (Tag str)
NFData a => NFData (Tag a)
StringLike str => TagRep (Tag str)
type Attribute str = (str, str)Source
An HTML attribute id="name" generates ("id","name")
type Row = IntSource
The row/line of a position, starting at 1
type Column = IntSource
The column of a position, starting at 1
Position manipulation
data Position Source
Constructors
Position !Row !Column
show/hide Instances
tagPosition :: Position -> Tag strSource
nullPosition :: PositionSource
positionChar :: Position -> Char -> PositionSource
positionString :: Position -> String -> PositionSource
Tag identification
isTagOpen :: Tag str -> BoolSource
Test if a Tag is a TagOpen
isTagClose :: Tag str -> BoolSource
Test if a Tag is a TagClose
isTagText :: Tag str -> BoolSource
Test if a Tag is a TagText
isTagWarning :: Tag str -> BoolSource
Test if a Tag is a TagWarning
isTagPosition :: Tag str -> BoolSource
Test if a Tag is a TagPosition
isTagOpenName :: Eq str => str -> Tag str -> BoolSource
Returns True if the Tag is TagOpen and matches the given name
isTagCloseName :: Eq str => str -> Tag str -> BoolSource
Returns True if the Tag is TagClose and matches the given name
Extraction
fromTagText :: Show str => Tag str -> strSource
Extract the string from within TagText, crashes if not a TagText
fromAttrib :: (Show str, Eq str, StringLike str) => str -> Tag str -> strSource
Extract an attribute, crashes if not a TagOpen. Returns "" if no attribute present.
maybeTagText :: Tag str -> Maybe strSource
Extract the string from within TagText, otherwise Nothing
maybeTagWarning :: Tag str -> Maybe strSource
Extract the string from within TagWarning, otherwise Nothing
innerText :: StringLike str => [Tag str] -> strSource
Extract all text content from tags (similar to Verbatim found in HaXml)
Produced by Haddock version 2.4.2