Parse HTML 5 in Elm. See https://www.w3.org/TR/html5/syntax.html
Run the parser on an entire HTML document
runDocument "<!--First comment--><!DOCTYPE html><!--Test stuffs--><html></html><!--Footer comment!-->"
-- => Ok { preambleComments = ["First comment"], doctype = "", predocComments = ["Test stuffs"], document = ([],[]), postdocComments = ["Footer comment!"] }An HTML node. It can either be:
An HTML document.
This simply separates the document into its component parts, as defined by the WHATWG Standard
An HTML attribute. For instance:
( "href", "https://elm-lang.org" )If you are building a parser of your own using elm/parser and
you need to parse HTML... This section is for you!
Turn a parser node back into its HTML string.
For instance:
Element "a"
[ ( "href", "https://elm-lang.org" ) ]
[ Text "Elm" ]
|> nodeToStringProduces <a href="https://elm-lang.org">Elm</a>.
Turn a document back into its HTML string.
For instance:
{ preambleComments = [ "Early!" ]
, doctype = "LEGACY \"My legacy string stuff\""
, predocComments = [ "Teehee!" ]
, document = ( [], [ Element "p" [] [ Text "Got it." ], Element "br" [] [] ] )
, postdocComments = [ "Smelly feet" ]
}
|> nodeToStringProduces <!--Early!--><!DOCTYPE html LEGACY \"My legacy string stuff\"><!--Teehee!--><html><p>Got it.</p><br /></html><!--Smelly feet-->.
Run the parser!