Idris2Doc : Text.Html.Elements

Text.Html.Elements

(source)
Functions to create HTML elements with compile time validation.

Each of the below function has the same name as in HTML.

The first parameter is the list of attributes.
The second parameter, if applicable is the element's content, which is in
most of the cases a list of children elements.

The return value is a list of element rather than a single element. This
allows an easier composition of the elements.

Definitions

mkNormalElem : String -> Elab ()
  Generates a normal element function using the element's name.

The function will be named `<name>` and will create a `<name>` element.

The type of the generated function is:

```idris2
(attrs : List Attribute)
-> (elems : List Element)
-> {auto 0 prf : IsRight (either_<name> attrs elems)}
-> List Element
```

The following example:

```idris2 example
%runElab mkNormalElem "a"
```

generates the below code:

```idris2
public export
a :
(attrs : List Attribute)
-> (elems : List Element)
-> {auto 0 prf : IsRight (either_a attrs elems)}
-> List Element
a attrs elems = raw_a attrs elems
```

Totality: total
Visibility: export
mkVoidElem : String -> Elab ()
  Generates a void element function using the element's name.

The function will be named `<name>` and will create a `<name>` element.

The type of the generated function is:

```idris2
(attrs : List Attribute)
-> {auto 0 prf : IsRight (either_<name> attrs)}
-> List Element
```

The following example:

```idris2 example
%runElab mkNormalElem "br"
```

generates the below code:

```idris2
public export
a :
(attrs : List Attribute)
-> {auto 0 prf : IsRight (either_br attrs)}
-> List Element
a attrs = raw_br attrs
```

Totality: total
Visibility: export
html5 : (attrs : List Attribute) -> (elems : List Element) -> {auto 0 _ : IsRight (either_html attrs elems)} -> Html
  Creates both a doctype preamble and a **html** element.

Accepted attributes (for the **html** element):

- Global

Accepted elements (for the **html** element):

- **head**
- **body**

Additional constraints (for the **html** element):

- The first element must be the **head** element.
- The second element must be the **body** element.
- There cannot be other elements.

Totality: total
Visibility: public export
title : (attrs : List Attribute) -> (text : NonWhitespace) -> {auto 0 _ : IsRight (either_title attrs text)} -> List Element
  Creates a **title** element.

Accepted attributes:

- Global

Accepted values:

- A non-empty, not white space only string.

Totality: total
Visibility: public export