Copyright | Copyright (C) 2006-2023 John MacFarlane |
---|---|
License | GNU GPL, version 2 or above |
Maintainer | John MacFarlane <jgm@berkeley.edu> |
Stability | alpha |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Functions for escaping and formatting XML.
Synopsis
- escapeCharForXML :: Char -> Text
- escapeStringForXML :: Text -> Text
- escapeNCName :: Text -> Text
- inTags :: (HasChars a, IsString a) => Bool -> Text -> [(Text, Text)] -> Doc a -> Doc a
- selfClosingTag :: (HasChars a, IsString a) => Text -> [(Text, Text)] -> Doc a
- inTagsSimple :: (HasChars a, IsString a) => Text -> Doc a -> Doc a
- inTagsIndented :: (HasChars a, IsString a) => Text -> Doc a -> Doc a
- toEntities :: Text -> Text
- toHtml5Entities :: Text -> Text
- fromEntities :: Text -> Text
- lookupEntity :: Text -> Maybe Text
- html4Attributes :: Set Text
- html5Attributes :: Set Text
- rdfaAttributes :: Set Text
Documentation
escapeCharForXML :: Char -> Text Source #
Escape one character as needed for XML.
escapeStringForXML :: Text -> Text Source #
Escape string as needed for XML. Entity references are not preserved.
escapeNCName :: Text -> Text Source #
Converts a string into an NCName, i.e., an XML name without colons.
Disallowed characters are escaped using ux%x
, where %x
is the
hexadecimal unicode identifier of the escaped character.
inTags :: (HasChars a, IsString a) => Bool -> Text -> [(Text, Text)] -> Doc a -> Doc a Source #
Put the supplied contents between start and end tags of tagType, with specified attributes and (if specified) indentation.
selfClosingTag :: (HasChars a, IsString a) => Text -> [(Text, Text)] -> Doc a Source #
Return a self-closing tag of tagType with specified attributes
inTagsSimple :: (HasChars a, IsString a) => Text -> Doc a -> Doc a Source #
Put the supplied contents between start and end tags of tagType.
inTagsIndented :: (HasChars a, IsString a) => Text -> Doc a -> Doc a Source #
Put the supplied contents in indented block btw start and end tags.
toEntities :: Text -> Text Source #
Escape all non-ascii characters using numerical entities.
toHtml5Entities :: Text -> Text Source #
Escape all non-ascii characters using HTML5 entities, falling back to numerical entities.
fromEntities :: Text -> Text Source #
Unescapes XML entities
lookupEntity :: Text -> Maybe Text #
rdfaAttributes :: Set Text Source #