Module Cow__Html

(X)HTML library

type t = Cow.Xml.t

A sequence of (X)HTML trees.

val doctype : string
val to_string : t ‑> string

to_string html is a valid (X)HTML5 polyglot string corresponding to the html structure.

val of_string : ?⁠enc:Cow.Xml.encoding ‑> string ‑> t

of_string ?enc html_str is the tree representation of html_str as decoded by enc. For more information about the default encoding, see Encoding.

Note that this function converts all standard entities into their corresponding UTF-8 symbol.

val output : ?⁠nl:bool ‑> ?⁠indent:int option ‑> ?⁠ns_prefix:(string ‑> string option) ‑> Xmlm.dest ‑> t ‑> unit

Outputs valid (X)HTML5 polyglot text from a t. Only non-void element handling is implemented so far. For more information about the parameters, see Xmlm.make_output.

val output_doc : ?⁠nl:bool ‑> ?⁠indent:int option ‑> ?⁠ns_prefix:(string ‑> string option) ‑> Xmlm.dest ‑> t ‑> unit

Outputs a valid (X)HTML5 polyglot document from a t. Only non-void element handling and HTML5 DOCTYPE is implemented so far. For more information about the parameters, see Xmlm.make_output.

HTML library

type rel = [
| `alternate
| `author
| `bookmark
| `help
| `license
| `next
| `nofollow
| `noreferrer
| `prefetch
| `prev
| `search
| `tag
]
type target = [
| `blank
| `parent
| `self
| `top
| `Frame of string
]
val a : ?⁠cls:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠hreflang:string ‑> ?⁠rel:rel ‑> ?⁠target:target ‑> ?⁠ty:string ‑> ?⁠title:string ‑> ?⁠href:Uri.t ‑> t ‑> t

a href html generate a link from html to href.

val img : ?⁠alt:string ‑> ?⁠width:int ‑> ?⁠height:int ‑> ?⁠ismap:Uri.t ‑> ?⁠title:string ‑> ?⁠cls:string ‑> ?⁠attrs:(string * string) list ‑> Uri.t ‑> t
val interleave : string array ‑> t list ‑> t list
val html_of_string : string ‑> t
val string : string ‑> t
val html_of_int : int ‑> t
val int : int ‑> t
val html_of_float : float ‑> t
val float : float ‑> t
type table = t array array
val html_of_table : ?⁠headings:bool ‑> table ‑> t
val nil : t
val empty : t
val concat : t list ‑> t
val list : t list ‑> t
val some : t option ‑> t
val append : t ‑> t ‑> t

append par ch appends ch to par

val (++) : t ‑> t ‑> t
module Create : sig ... end

HTML nodes

type node = ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> t ‑> t

The type for nodes.

val tag : string ‑> node

tag name t returns <name>t</name> where <name> can have attributes "class" (if cls is given), "id" (if id is given) and other attributes specified by attrs. You are encouraged not to use tag but prefer the specialized versions below whenever possible.

val div : node

div ~cls:"cl" t is <div class="cl">t</div>.

val span : node

div ~cls:"cl" t is <div class="cl">t</div>.

val input : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠ty:string ‑> string ‑> t

input v returns a button with value "v".

val br : t
val hr : t
val wbr : t

A "Word Break Opportunity" node.

val param : name:string ‑> string ‑> t

param name value return a <param> node to be used in <object>.

val embed : ?⁠width:int ‑> ?⁠height:int ‑> ?⁠ty:string ‑> ?⁠attrs:(string * string) list ‑> Uri.t ‑> t

embed uri returns an <embed> node for uri.

val col : ?⁠cls:string ‑> ?⁠style:string ‑> ?⁠attrs:(string * string) list ‑> int ‑> t

col n return a <col span="n"/> tag to specify properties of columns in a <colgroup>.

val source : ?⁠media:string ‑> ?⁠ty:string ‑> Uri.t ‑> t

source uri returns a <source> tag to be used in an <audio> or <video> tag. It specifies an alternative location uri and its type ty for the browser to choose from.

val track : ?⁠default:bool ‑> ?⁠label:string ‑> [ `Captions | `Chapters | `Descriptions | `Metadata | `Subtitles of string ] ‑> Uri.t ‑> t

track uri returns a <track> node to insert in an <audio> or <video> tag. The argument of `Subtitles is the language of the track.

val keygen : ?⁠autofocus:bool ‑> ?⁠disabled:bool ‑> ?⁠form:string ‑> ?⁠challenge:bool ‑> ?⁠keytype:[ `RSA | `DSA | `EC ] ‑> string ‑> t

keygen name return a <keygen> tag that specifies a key-pair generator field used for forms.

val anchor : string ‑> t
val h1 : node
val h2 : node
val h3 : node
val h4 : node
val h5 : node
val h6 : node
val li : node
val dt : node
val dd : node
val ul : ?⁠add_li:bool ‑> ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠licls:string ‑> t list ‑> t
val ol : ?⁠add_li:bool ‑> ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠licls:string ‑> t list ‑> t
val dl : ?⁠add_dtdd:bool ‑> ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠dtcls:string ‑> ?⁠ddcls:string ‑> (t * t) list ‑> t
val p : node
val blockquote : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠cite:Uri.t ‑> t ‑> t
val pre : node
val figure : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠figcaption:t ‑> t ‑> t
val main : node
val s : node

The <s> tag specifies text that is no longer correct, accurate or relevant. The <s> tag should not be used to define replaced or deleted text, use the <del> for that purpose.

val cite : node
val q : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠cite:Uri.t ‑> t ‑> t
val dfn : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠title:string ‑> t ‑> t
val abbr : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠title:string ‑> t ‑> t
val data : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> value:string ‑> t ‑> t
val time : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠datetime:string ‑> t ‑> t
val code : node
val sub : node
val sup : node
val b : node
val u : node
val mark : node
val bdi : node
val bdo : node
val ruby : node
val rb : node
val rt : node
val rtc : node
val rp : node
val aside : node
val ins : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠cite:Uri.t ‑> ?⁠datetime:string ‑> t ‑> t
val del : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠cite:Uri.t ‑> ?⁠datetime:string ‑> t ‑> t
val html : node
val title : node
val header : node
val body : node
val nav : node
val section : node
val article : node
val address : node
val script : ?⁠src:Uri.t ‑> ?⁠ty:string ‑> ?⁠charset:string ‑> t ‑> t

Head elements

val head : node
val meta : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠name:string ‑> ?⁠content:string ‑> ?⁠charset:string ‑> (string * string) list ‑> t

meta attrs returns a <meta> tag to be put in the <head>.

val base : ?⁠cls:string ‑> ?⁠id:string ‑> ?⁠attrs:(string * string) list ‑> ?⁠target:string ‑> Uri.t ‑> t

base uri returns a <base href="uri" /> tag that specifies the base URI for all relative URLs in the HTML document.

val style : ?⁠media:string ‑> ?⁠scoped:bool ‑> string ‑> t

style css return a <style> tag giving the css directives. This tag is typically found in the <head>. In the <body> of the document, scoped must be set to true.

Discouraged HTML tags

Most of the tags below are not deprecated in HTML5 but are discouraged in favor of using CSS stylesheets.

val small : node
val i : node

In HTML5, it is not guaranteed that it will render text in italics.

val tt : node

The <tt> tag is not supported in HTML5.

val em : node
val strong : node
val var : node
val kbd : node
val samp : node