mangrove-0.1.0.0: src/Web/Mangrove/Parse/Common/Error.hs
{-|
Description: Well-typed errors which may be raised by the HTML parsing algorithm.
Copyright: (c) 2020 Sam May
License: MPL-2.0
Maintainer: ag.eitilt@gmail.com
Stability: experimental
Portability: portable
-}
module Web.Mangrove.Parse.Common.Error
( ParseError ( .. )
) where
import qualified Data.ByteString.Short as BS.SH
import qualified Data.Text as T
import qualified Numeric.Natural as Z
import Web.Willow.DOM
-- | __HTML:__
-- @[parse errors]
-- (https://html.spec.whatwg.org/multipage/parsing.html#parse-errors)@
-- (constructor names directly reflect the identifiers in the spec)
--
-- Indicators that something syntactically unexpected was found in an HTML
-- file. Given the focus on recovery in the parse algorithm, these are more
-- properly warnings than errors, but the name follows that in the
-- specification.
--
-- This datatype consists of the union of the errors raised by any of the
-- various stages of the algorithm; no distinction is made between an "encoding
-- error" and a "tree-building error".
--
-- Several constructors wrap a payload which would otherwise be unrecoverable
-- from the DOM, to enable richer error reporting.
data ParseError
= AbruptTemplateFragment
| AbruptClosingOfEmptyComment
| AbruptDoctypePublicIdentifier
| AbruptDoctypeSystemIdentifier
| AbsenceOfDigitsInNumericCharacterReference
| BREndTag
| CDataInHtmlContent
| CharacterReferenceOutsideUnicodeRange Z.Natural
| ControlCharacterInInputStream
| ControlCharacterReference
| DuplicateAttribute BasicAttribute
| DuplicateSingletonElement ElementParams
| EndTagWithAttributes
| EndTagWithTrailingSolidus
| EOFBeforeTagName
| EOFInCData
| EOFInComment
| EOFInDoctype
| EOFInScriptHtmlCommentLikeText
| EOFInTag -- Payload?
| EOFInTemplate
| EOFInText
| FramesetInBody ElementParams
| IncompletelyClosedFormattingElement
| IncorrectlyClosedComment
| IncorrectlyOpenedComment
| InvalidByteSequence BS.SH.ShortByteString
| InvalidCharacterSequenceAfterDoctypeName
| InvalidFirstCharacterOfTagName
| LegacyDoctype
| MalformedTableStructure ElementParams
| MissingAttributeValue
| MissingDoctype
| MissingDoctypeName
| MissingDoctypePublicIdentifier
| MissingDoctypeSystemIdentifier
| MissingEndTagName
| MissingQuoteBeforeDoctypePublicIdentifier
| MissingQuoteBeforeDoctypeSystemIdentifier
| MissingSemicolonAfterCharacterReference
| MissingWhitespaceAfterDoctypePublicKeyword
| MissingWhitespaceAfterDoctypeSystemKeyword
| MissingWhitespaceBeforeDoctypeName
| MissingWhitespaceBetweenAttributes
| MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers
| NestedComment
| NestedElementForAdoptionAgency
| NestedNonRecursiveElement
| NestedSingletonElement
| NoncharacterCharacterReference Char
| NoncharacterInInputStream
| NonVoidHtmlElementStartTagWithTrailingSolidus
| NullCharacterReference
| ObsoleteTagName T.Text
| OverlappingFormattingElements
| OverlappingHeaderElements
| OverlappingInputElements
| SurrogateCharacterReference Char
| SurrogateInInputStream
| UnexpectedCharacterAfterDoctypeSystemIdentifier Char
| UnexpectedCharacterInAttributeName
| UnexpectedCharacterInUnquotedAttributeValue
| UnexpectedContentAfterBody
| UnexpectedDescendantElement ElementParams
| UnexpectedDoctype DocumentTypeParams
| UnexpectedElementInTableStructure
| UnexpectedElementWithImpliedEndTag
| UnexpectedEqualsSignBeforeAttributeName
| UnexpectedEndColInColumnGroup
| UnexpectedEndOfBody
| UnexpectedEndTag ElementParams
| UnexpectedFormattingElementOutOfScope
| UnexpectedHtmlElementInForeignContent
| UnexpectedMetadataOutsideOfHead
| UnexpectedNodeAfterFrameset -- Payload?
| UnexpectedNodeInFrameset -- Payload?
| UnexpectedNodeInHeadNoscript
| UnexpectedNodeInTableStructure
| UnexpectedNullCharacter
| UnexpectedQuestionMarkInsteadOfTagName
| UnexpectedSolidusInTag
| UnexpectedTableCellOutsideOfRow
| UnexpectedTextInTableStructure
| UnknownNamedCharacterReference
| UnmatchedEndTag ElementParams
| UnmatchedEndPTag
| XmlnsAttribtuteWithMismatchedValue
deriving ( Eq, Show, Read )