| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Data.Markup
Description
Core markup data types.
Synopsis
- data Standard
- newtype Markup = Markup {}
- data Token
- = OpenTag !OpenTagType !NameTag ![Attr]
- | EndTag !NameTag
- | Content !ByteString
- | Comment !ByteString
- | Decl !ByteString ![Attr]
- | Doctype !ByteString
- data OpenTagType
- data Attr = Attr {}
- type AttrName = ByteString
- type AttrValue = ByteString
- type Element = Tree Token
- type NameTag = ByteString
- data RenderStyle
- newtype TokenParser e a = TokenParser {}
Documentation
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.
Instances
| Eq Standard Source # | |
| Ord Standard Source # | |
Defined in Data.Markup | |
| Data Standard Source # | |
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 # | |
Defined in Data.Markup | |
| Show Standard Source # | |
| type Rep Standard Source # | |
Instances
| Monoid Markup Source # | |||||
| Semigroup Markup Source # | |||||
| Eq Markup Source # | |||||
| Ord Markup Source # | |||||
| Data Markup Source # | |||||
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 # | |||||
Defined in Data.Markup Associated Types
| |||||
| Show Markup Source # | |||||
| type Rep Markup Source # | |||||
Defined in Data.Markup | |||||
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:
- As an intermediary representation of markup between
ByteStringandMarkup. - As the primitives of
MarkupElements
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
data OpenTagType Source #
Whether an opening tag is a start tag or an empty element tag.
Constructors
| StartTag | |
| EmptyElemTag |
Instances
| Eq OpenTagType Source # | |||||
Defined in Data.Markup | |||||
| Ord OpenTagType Source # | |||||
Defined in Data.Markup Methods compare :: OpenTagType -> OpenTagType -> Ordering # (<) :: OpenTagType -> OpenTagType -> Bool # (<=) :: OpenTagType -> OpenTagType -> Bool # (>) :: OpenTagType -> OpenTagType -> Bool # (>=) :: OpenTagType -> OpenTagType -> Bool # max :: OpenTagType -> OpenTagType -> OpenTagType # min :: OpenTagType -> OpenTagType -> OpenTagType # | |||||
| Data OpenTagType Source # | |||||
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 # | |||||
Defined in Data.Markup Associated Types
| |||||
| Show OpenTagType Source # | |||||
Defined in Data.Markup Methods showsPrec :: Int -> OpenTagType -> ShowS # show :: OpenTagType -> String # showList :: [OpenTagType] -> ShowS # | |||||
| type Rep OpenTagType 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.
Instances
| Eq Attr Source # | |||||
| Ord Attr Source # | |||||
| Data Attr Source # | |||||
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 # 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 # | |||||
Defined in Data.Markup Associated Types
| |||||
| Show Attr Source # | |||||
| type Rep Attr Source # | |||||
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 NameTag = ByteString Source #
Name of token
data RenderStyle Source #
Indented 0 puts newlines in between the tags.
Instances
| Eq RenderStyle Source # | |||||
Defined in Data.Markup | |||||
| Ord RenderStyle Source # | |||||
Defined in Data.Markup Methods compare :: RenderStyle -> RenderStyle -> Ordering # (<) :: RenderStyle -> RenderStyle -> Bool # (<=) :: RenderStyle -> RenderStyle -> Bool # (>) :: RenderStyle -> RenderStyle -> Bool # (>=) :: RenderStyle -> RenderStyle -> Bool # max :: RenderStyle -> RenderStyle -> RenderStyle # min :: RenderStyle -> RenderStyle -> RenderStyle # | |||||
| Data RenderStyle Source # | |||||
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 # | |||||
Defined in Data.Markup Associated Types
| |||||
| Read RenderStyle Source # | |||||
Defined in Data.Markup Methods readsPrec :: Int -> ReadS RenderStyle # readList :: ReadS [RenderStyle] # readPrec :: ReadPrec RenderStyle # readListPrec :: ReadPrec [RenderStyle] # | |||||
| Show RenderStyle Source # | |||||
Defined in Data.Markup Methods showsPrec :: Int -> RenderStyle -> ShowS # show :: RenderStyle -> String # showList :: [RenderStyle] -> ShowS # | |||||
| type Rep RenderStyle Source # | |||||
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 | |