On this page:
Content
Document
Document.content
Document.doctype
Document.quirks_  mode
Document  Type
Document  Type.name
Document  Type.public
Document  Type.system
Document.Quirks  Mode
Document.Quirks  Mode.no_  quirks
Document.Quirks  Mode.quirks
Document.Quirks  Mode.limited_  quirks
Element
Element.name
Element.attributes
Element.content
Element.is_  template
Element.is_  self_  closing
Element.namespace
Attribute
Attribute.name
Attribute.value
Comment
Comment.data
Inject
Inject.text
0.45+9.1

1 HTML Document Representation🔗ℹ

enumeration

enum html.Content

| ~is_a html.Element

| ~is_a String

| ~is_a html.Comment

An enumeration of representations used for the content of HTML documents: an html.Element for content that is written in HTML roughly as, <name></name> as contains nested content, a String for textual content, or html.Comment for a comment written as <!---->. This content is within html.Document to represent an overall HTML document.

class

class html.Document(

  ~content: content :: List.of(html.Content) = [],

  ~doctype: doctype :: maybe(html.DocumentType) = html.DocumentType(),

  ~quirks_mode: quirks_mode :: html.Document.QuirksMode = #'no_quirks

)

 

class

class html.DocumentType(

  ~name: name :: String = "html",

  ~public: public :: maybe(String) = #false,

  ~system: system :: maybe(String) = #false

)

 

enumeration

enum html.Document.QuirksMode

| no_quirks

| quirks

| limited_quirks

Represents an HTML document.

The content field is normally the most interesting component.

The doctype field is a html.DocumentType to represent an HTML document that starts <!DOCTYPE>. The name field in html.DocumentType is the name after DOCTYPE, which is normally html. The public and system fields will be values other than #false only for legacy specifications within DOCTYPE.

The quirks_mode fields of html.Document is based on the doctype field, and it indicates certain aspects of an input document was parsed.

class

class html.Element(

  ~name: name :: String = "div",

  ~attributes: attributes :: List.of(html.Attribute) = [],

  ~content: content :: List.of(html.Content) = [],

  ~is_template: is_template :: Boolean = #false,

  ~is_self_closing: is_self_closing :: Boolean = #false,

  ~namespace: namespace :: Symbol = #'html

)

 

class

class html.Attribute(

  ~name: name :: String,

  ~value: value :: String

)

Represents an element within an HTML document that is written roughly as <name></name>, optionally with attributes withing the opening tag and/or content between the opening and closing tag.

When parsing HTML with html.read, name is case-folded, but html.write uses name verbatim; in particular, it assumes that the name is valid for an HTML element. Similarly, html.read case-folds name for an attribute, and html.write assumes that the name is valid. When no value is supplied for an attribute, html.read uses "" as the attribute’s value.

The is_template field will have #true when the element is parsed from a HTML document using element as the element name and #'html as the namespace. HTML template content is parsed specially.

The is_self_closing field is #true when the element is—or should be, per the HTML specification—parsed from <name/>. The html.write function uses this field to print similarly, as long as the content field has [].

The namespace field indicates the namespace for name. It is normally #'html, but #'svg and #'mathml are other possibilities.

class

class html.Comment(~data: data :: String = "")

Represents a comment within an HTML document, which is written as <!---->.

class

class html.Inject(~text: text :: String)

Represents literal text to be written as-is within an HTML document (or a document that is otherwise valid HTML).

Use html.Inject to create output that does not adhere to the HTML specification or to create valid HTML in a format other than the one that html.write would use.