markup-parse
Safe HaskellNone
LanguageGHC2024

Data.Markup

Description

Core markup data types.

Synopsis

Documentation

data Standard Source #

From a parsing pov, Html & Xml (& Svg) are close enough that they share a lot of parsing logic, so that parsing and printing just need some tweaking.

The xml parsing logic is based on the XML productions found in https://www.w3.org/TR/xml/

The html parsing was based on a reading of html-parse, but ignores the various 'x00' to 'xfffd' & eof directives that form part of the html standards.

Constructors

Html 
Xml 

Instances

Instances details
Eq Standard Source # 
Instance details

Defined in Data.Markup

Ord Standard Source # 
Instance details

Defined in Data.Markup

Data Standard Source # 
Instance details

Defined in Data.Markup

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Standard -> c Standard #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Standard #

toConstr :: Standard -> Constr #

dataTypeOf :: Standard -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Standard) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Standard) #

gmapT :: (forall b. Data b => b -> b) -> Standard -> Standard #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Standard -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Standard -> r #

gmapQ :: (forall d. Data d => d -> u) -> Standard -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Standard -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Standard -> m Standard #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Standard -> m Standard #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Standard -> m Standard #

Generic Standard Source # 
Instance details

Defined in Data.Markup

Associated Types

type Rep Standard 
Instance details

Defined in Data.Markup

type Rep Standard = D1 ('MetaData "Standard" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "Html" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Xml" 'PrefixI 'False) (U1 :: Type -> Type))

Methods

from :: Standard -> Rep Standard x #

to :: Rep Standard x -> Standard #

Show Standard Source # 
Instance details

Defined in Data.Markup

type Rep Standard Source # 
Instance details

Defined in Data.Markup

type Rep Standard = D1 ('MetaData "Standard" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "Html" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Xml" 'PrefixI 'False) (U1 :: Type -> Type))

newtype Markup Source #

A list of Elements or Tree Tokens

Constructors

Markup 

Fields

Instances

Instances details
Monoid Markup Source # 
Instance details

Defined in Data.Markup

Semigroup Markup Source # 
Instance details

Defined in Data.Markup

Eq Markup Source # 
Instance details

Defined in Data.Markup

Methods

(==) :: Markup -> Markup -> Bool #

(/=) :: Markup -> Markup -> Bool #

Ord Markup Source # 
Instance details

Defined in Data.Markup

Data Markup Source # 
Instance details

Defined in Data.Markup

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Markup -> c Markup #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Markup #

toConstr :: Markup -> Constr #

dataTypeOf :: Markup -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Markup) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Markup) #

gmapT :: (forall b. Data b => b -> b) -> Markup -> Markup #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Markup -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Markup -> r #

gmapQ :: (forall d. Data d => d -> u) -> Markup -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Markup -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Markup -> m Markup #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Markup -> m Markup #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Markup -> m Markup #

Generic Markup Source # 
Instance details

Defined in Data.Markup

Associated Types

type Rep Markup 
Instance details

Defined in Data.Markup

type Rep Markup = D1 ('MetaData "Markup" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'True) (C1 ('MetaCons "Markup" 'PrefixI 'True) (S1 ('MetaSel ('Just "elements") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Element])))

Methods

from :: Markup -> Rep Markup x #

to :: Rep Markup x -> Markup #

Show Markup Source # 
Instance details

Defined in Data.Markup

type Rep Markup Source # 
Instance details

Defined in Data.Markup

type Rep Markup = D1 ('MetaData "Markup" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'True) (C1 ('MetaCons "Markup" 'PrefixI 'True) (S1 ('MetaSel ('Just "elements") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Element])))

data Token Source #

A Markup token. The term is borrowed from HTML standards but is used across Html and Xml in this library.

Note that the Token type is used in two slightly different contexts:

Specifically, an EndTag will occur in a list of tokens, but not as a primitive in Markup. It may turn out to be better to have two different types for these two uses and future iterations of this library may head in this direction.

Constructors

OpenTag !OpenTagType !NameTag ![Attr]

A tag. https://developer.mozilla.org/en-US/docs/Glossary/Tag

EndTag !NameTag

A closing tag.

Content !ByteString

The content between tags.

Comment !ByteString

Contents of a comment.

Decl !ByteString ![Attr]

Contents of a declaration

Doctype !ByteString

Contents of a doctype declaration.

Instances

Instances details
Eq Token Source # 
Instance details

Defined in Data.Markup

Methods

(==) :: Token -> Token -> Bool #

(/=) :: Token -> Token -> Bool #

Ord Token Source # 
Instance details

Defined in Data.Markup

Methods

compare :: Token -> Token -> Ordering #

(<) :: Token -> Token -> Bool #

(<=) :: Token -> Token -> Bool #

(>) :: Token -> Token -> Bool #

(>=) :: Token -> Token -> Bool #

max :: Token -> Token -> Token #

min :: Token -> Token -> Token #

Data Token Source # 
Instance details

Defined in Data.Markup

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Token -> c Token #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Token #

toConstr :: Token -> Constr #

dataTypeOf :: Token -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Token) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Token) #

gmapT :: (forall b. Data b => b -> b) -> Token -> Token #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Token -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Token -> r #

gmapQ :: (forall d. Data d => d -> u) -> Token -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Token -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Token -> m Token #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Token -> m Token #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Token -> m Token #

Generic Token Source # 
Instance details

Defined in Data.Markup

Methods

from :: Token -> Rep Token x #

to :: Rep Token x -> Token #

Show Token Source # 
Instance details

Defined in Data.Markup

Methods

showsPrec :: Int -> Token -> ShowS #

show :: Token -> String #

showList :: [Token] -> ShowS #

type Rep Token Source # 
Instance details

Defined in Data.Markup

data OpenTagType Source #

Whether an opening tag is a start tag or an empty element tag.

Constructors

StartTag 
EmptyElemTag 

Instances

Instances details
Eq OpenTagType Source # 
Instance details

Defined in Data.Markup

Ord OpenTagType Source # 
Instance details

Defined in Data.Markup

Data OpenTagType Source # 
Instance details

Defined in Data.Markup

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> OpenTagType -> c OpenTagType #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c OpenTagType #

toConstr :: OpenTagType -> Constr #

dataTypeOf :: OpenTagType -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c OpenTagType) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OpenTagType) #

gmapT :: (forall b. Data b => b -> b) -> OpenTagType -> OpenTagType #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OpenTagType -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OpenTagType -> r #

gmapQ :: (forall d. Data d => d -> u) -> OpenTagType -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> OpenTagType -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> OpenTagType -> m OpenTagType #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> OpenTagType -> m OpenTagType #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> OpenTagType -> m OpenTagType #

Generic OpenTagType Source # 
Instance details

Defined in Data.Markup

Associated Types

type Rep OpenTagType 
Instance details

Defined in Data.Markup

type Rep OpenTagType = D1 ('MetaData "OpenTagType" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "StartTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EmptyElemTag" 'PrefixI 'False) (U1 :: Type -> Type))
Show OpenTagType Source # 
Instance details

Defined in Data.Markup

type Rep OpenTagType Source # 
Instance details

Defined in Data.Markup

type Rep OpenTagType = D1 ('MetaData "OpenTagType" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "StartTag" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EmptyElemTag" 'PrefixI 'False) (U1 :: Type -> Type))

data Attr Source #

An attribute of a tag

In parsing, boolean attributes, which are not required to have a value in HTML, will be set a value of "", which is ok. But this will then be rendered.

Constructors

Attr 

Instances

Instances details
Eq Attr Source # 
Instance details

Defined in Data.Markup

Methods

(==) :: Attr -> Attr -> Bool #

(/=) :: Attr -> Attr -> Bool #

Ord Attr Source # 
Instance details

Defined in Data.Markup

Methods

compare :: Attr -> Attr -> Ordering #

(<) :: Attr -> Attr -> Bool #

(<=) :: Attr -> Attr -> Bool #

(>) :: Attr -> Attr -> Bool #

(>=) :: Attr -> Attr -> Bool #

max :: Attr -> Attr -> Attr #

min :: Attr -> Attr -> Attr #

Data Attr Source # 
Instance details

Defined in Data.Markup

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Attr -> c Attr #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Attr #

toConstr :: Attr -> Constr #

dataTypeOf :: Attr -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Attr) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Attr) #

gmapT :: (forall b. Data b => b -> b) -> Attr -> Attr #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Attr -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Attr -> r #

gmapQ :: (forall d. Data d => d -> u) -> Attr -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Attr -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Attr -> m Attr #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Attr -> m Attr #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Attr -> m Attr #

Generic Attr Source # 
Instance details

Defined in Data.Markup

Associated Types

type Rep Attr 
Instance details

Defined in Data.Markup

type Rep Attr = D1 ('MetaData "Attr" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "Attr" 'PrefixI 'True) (S1 ('MetaSel ('Just "attrName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AttrName) :*: S1 ('MetaSel ('Just "attrValue") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AttrValue)))

Methods

from :: Attr -> Rep Attr x #

to :: Rep Attr x -> Attr #

Show Attr Source # 
Instance details

Defined in Data.Markup

Methods

showsPrec :: Int -> Attr -> ShowS #

show :: Attr -> String #

showList :: [Attr] -> ShowS #

type Rep Attr Source # 
Instance details

Defined in Data.Markup

type Rep Attr = D1 ('MetaData "Attr" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "Attr" 'PrefixI 'True) (S1 ('MetaSel ('Just "attrName") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AttrName) :*: S1 ('MetaSel ('Just "attrValue") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 AttrValue)))

type AttrName = ByteString Source #

Name of an attribute.

type AttrValue = ByteString Source #

Value of an attribute. "" is equivalent to true with respect to boolean attributes.

type Element = Tree Token Source #

Most functions return a Markup rather than an Element because it is often more ergonomic to use the free monoid (aka a list) in preference to returning a Maybe Element (say).

type NameTag = ByteString Source #

Name of token

data RenderStyle Source #

Indented 0 puts newlines in between the tags.

Constructors

Compact 
Indented Int 

Instances

Instances details
Eq RenderStyle Source # 
Instance details

Defined in Data.Markup

Ord RenderStyle Source # 
Instance details

Defined in Data.Markup

Data RenderStyle Source # 
Instance details

Defined in Data.Markup

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RenderStyle -> c RenderStyle #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RenderStyle #

toConstr :: RenderStyle -> Constr #

dataTypeOf :: RenderStyle -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RenderStyle) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RenderStyle) #

gmapT :: (forall b. Data b => b -> b) -> RenderStyle -> RenderStyle #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RenderStyle -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RenderStyle -> r #

gmapQ :: (forall d. Data d => d -> u) -> RenderStyle -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> RenderStyle -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> RenderStyle -> m RenderStyle #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RenderStyle -> m RenderStyle #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RenderStyle -> m RenderStyle #

Generic RenderStyle Source # 
Instance details

Defined in Data.Markup

Associated Types

type Rep RenderStyle 
Instance details

Defined in Data.Markup

type Rep RenderStyle = D1 ('MetaData "RenderStyle" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "Compact" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Indented" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))
Read RenderStyle Source # 
Instance details

Defined in Data.Markup

Show RenderStyle Source # 
Instance details

Defined in Data.Markup

type Rep RenderStyle Source # 
Instance details

Defined in Data.Markup

type Rep RenderStyle = D1 ('MetaData "RenderStyle" "Data.Markup" "markup-parse-0.3.0.0-inplace" 'False) (C1 ('MetaCons "Compact" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Indented" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

newtype TokenParser e a Source #

TokenParser: semantic phase parser operating on token streams

State-threading parser over token lists with error/warning accumulation.

Constructors

TokenParser 

Fields