package cow

  1. Overview
  2. Docs

Module Cow.HtmlSource

(X)HTML library

Sourcetype t = Xml.t

A sequence of (X)HTML trees.

Sourceval doctype : string
Sourceval to_string : t -> string

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

Sourceval of_string : ?enc: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.

Sourceval 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.

Sourceval 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

Sourcetype rel = [
  1. | `alternate
  2. | `author
  3. | `bookmark
  4. | `help
  5. | `license
  6. | `next
  7. | `nofollow
  8. | `noreferrer
  9. | `prefetch
  10. | `prev
  11. | `search
  12. | `tag
]
Sourcetype target = [
  1. | `blank
  2. | `parent
  3. | `self
  4. | `top
  5. | `Frame of string
]
Sourceval 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.

  • parameter title

    specifies extra information about the element that is usually as a tooltip text when the mouse moves over the element. Default: None.

  • parameter target

    Specifies where to open the linked document.

  • parameter rel

    Specifies the relationship between the current document and the linked document. Default: None.

  • parameter hreflang

    the language of the linked document. Default: None.

  • parameter ty

    Specifies the media type of the linked document.

Sourceval img : ?alt:string -> ?width:int -> ?height:int -> ?ismap:Uri.t -> ?title:string -> ?cls:string -> ?attrs:(string * string) list -> Uri.t -> t
Sourceval interleave : string array -> t list -> t list
Sourceval html_of_string : string -> t
Sourceval string : string -> t
Sourceval html_of_int : int -> t
  • deprecated

    use int

Sourceval int : int -> t
Sourceval html_of_float : float -> t
Sourceval float : float -> t
Sourcetype table = t array array
Sourceval html_of_table : ?headings:bool -> table -> t
Sourceval nil : t
Sourceval empty : t
Sourceval concat : t list -> t
Sourceval list : t list -> t
Sourceval some : t option -> t
Sourceval append : t -> t -> t

append par ch appends ch to par

Sourceval (++) : t -> t -> t
Sourcemodule Create : sig ... end

HTML nodes

Sourcetype node = ?cls:string -> ?id:string -> ?attrs:(string * string) list -> t -> t

The type for nodes.

Sourceval 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.

Sourceval div : node

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

Sourceval span : node

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

Sourceval input : ?cls:string -> ?id:string -> ?attrs:(string * string) list -> ?ty:string -> string -> t

input v returns a button with value "v".

  • parameter ty

    the type of the input. Default: "button".

Sourceval br : t
Sourceval hr : t
Sourceval wbr : t

A "Word Break Opportunity" node.

Sourceval param : name:string -> string -> t

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

Sourceval embed : ?width:int -> ?height:int -> ?ty:string -> ?attrs:(string * string) list -> Uri.t -> t

embed uri returns an <embed> node for uri.

Sourceval 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>.

Sourceval 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.

Sourceval 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.

Sourceval 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.

Sourceval anchor : string -> t
Sourceval h1 : node
Sourceval h2 : node
Sourceval h3 : node
Sourceval h4 : node
Sourceval h5 : node
Sourceval h6 : node
Sourceval li : node
Sourceval dt : node
Sourceval dd : node
Sourceval ul : ?add_li:bool -> ?cls:string -> ?id:string -> ?attrs:(string * string) list -> ?licls:string -> t list -> t
Sourceval ol : ?add_li:bool -> ?cls:string -> ?id:string -> ?attrs:(string * string) list -> ?licls:string -> t list -> t
Sourceval dl : ?add_dtdd:bool -> ?cls:string -> ?id:string -> ?attrs:(string * string) list -> ?dtcls:string -> ?ddcls:string -> (t * t) list -> t
Sourceval p : node
Sourceval blockquote : ?cls:string -> ?id:string -> ?attrs:(string * string) list -> ?cite:Uri.t -> t -> t
Sourceval pre : node
Sourceval figure : ?cls:string -> ?id:string -> ?attrs:(string * string) list -> ?figcaption:t -> t -> t
Sourceval main : node
Sourceval 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.

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

Head elements

Sourceval head : node

link uri returns a <link href="uri"> element to be put in the <head>.

Sourceval 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>.

Sourceval 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.

Sourceval 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.

  • parameter scoped

    Specifies that the styles only apply to this element's parent element and that element's child elements. Only for HTML5. Default: false.

  • parameter media

    Specifies what media/device the media resource is optimized for.

Discouraged HTML tags

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

Sourceval small : node
Sourceval i : node

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

  • deprecated

    Use CSS instead.

Sourceval tt : node

The <tt> tag is not supported in HTML5.

  • deprecated

    Use CSS instead.

Sourceval em : node
Sourceval strong : node
Sourceval var : node
Sourceval kbd : node
Sourceval samp : node