From 7b3e70172e3366a4df3224b26e355d1b08541785 Mon Sep 17 00:00:00 2001 From: Yawar Amin Date: Sat, 27 Apr 2024 01:46:26 -0400 Subject: [PATCH] docs --- dream-html/Dream_html/Aria/index.html | 2 +- dream-html/Dream_html/HTML/index.html | 20 +- dream-html/Dream_html/Hx/index.html | 2 +- dream-html/Dream_html/Livereload/index.html | 4 +- dream-html/Dream_html/MathML/index.html | 2 +- dream-html/Dream_html/SVG/index.html | 2 +- dream-html/Dream_html/index.html | 34 +-- dream-html/index.html | 2 +- index.html | 311 +++++++++++++++++++- odoc.support/odoc.css | 2 +- pure-html/Pure_html/Aria/index.html | 2 + pure-html/Pure_html/HTML/index.html | 161 ++++++++++ pure-html/Pure_html/Hx/index.html | 2 + pure-html/Pure_html/MathML/index.html | 2 + pure-html/Pure_html/SVG/index.html | 3 + pure-html/Pure_html/index.html | 11 + pure-html/index.html | 2 + 17 files changed, 510 insertions(+), 54 deletions(-) create mode 100644 pure-html/Pure_html/Aria/index.html create mode 100644 pure-html/Pure_html/HTML/index.html create mode 100644 pure-html/Pure_html/Hx/index.html create mode 100644 pure-html/Pure_html/MathML/index.html create mode 100644 pure-html/Pure_html/SVG/index.html create mode 100644 pure-html/Pure_html/index.html create mode 100644 pure-html/index.html diff --git a/dream-html/Dream_html/Aria/index.html b/dream-html/Dream_html/Aria/index.html index e1c4152..7c76acf 100644 --- a/dream-html/Dream_html/Aria/index.html +++ b/dream-html/Dream_html/Aria/index.html @@ -1,2 +1,2 @@ -Aria (dream-html.Dream_html.Aria)

Module Dream_html.Aria

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/

val activedescendant : _ string_attr
val atomic : attr
val autocomplete : [ `inline | `list | `both ] to_attr
val braillelabel : _ string_attr
val brailleroledescription : _ string_attr
val busy : attr
val checked : [ `false_ | `true_ | `mixed ] to_attr
val colcount : int to_attr
val colindextext : _ string_attr
val colspan : int to_attr
val controls : _ string_attr
val current : [ `page | `step | `location | `date | `time | `true_ ] to_attr
val describedby : _ string_attr
val description : _ string_attr
val details : _ string_attr
val disabled : attr
val errormessage : _ string_attr
val expanded : bool to_attr
val flowto : _ string_attr
val haspopup : [ `true_ | `menu | `listbox | `tree | `grid | `dialog ] to_attr
val hidden : bool to_attr
val invalid : [ `grammar | `spelling | `true_ ] to_attr
val keyshortcuts : _ string_attr
val label : _ string_attr
val labelledby : _ string_attr
val level : int to_attr
val live : [ `assertive | `polite ] to_attr
val modal : attr
val multiline : attr
val multiselectable : attr
val orientation : [ `horizontal | `vertical ] to_attr
val owns : _ string_attr
val placeholder : _ string_attr
val posinset : int to_attr
val pressed : [ `false_ | `mixed | `true_ ] to_attr
val readonly : attr
val relevant : [ `additions | `all | `removals | `text ] to_attr
val required : attr
val roledescription : _ string_attr
val rowcount : int to_attr
val rowindex : int to_attr
val rowindextext : _ string_attr
val rowspan : int to_attr
val selected : bool to_attr
val setsize : int to_attr
val sort : [ `ascending | `descending | `other ] to_attr
val valuemax : float to_attr
val valuemin : float to_attr
val valuenow : float to_attr
val valuetext : _ string_attr
+Aria (dream-html.Dream_html.Aria)

Module Dream_html.Aria

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/

val activedescendant : _ string_attr
val atomic : attr
val autocomplete : [ `inline | `list | `both ] to_attr
val braillelabel : _ string_attr
val brailleroledescription : _ string_attr
val busy : attr
val checked : [ `false_ | `true_ | `mixed ] to_attr
val colcount : int to_attr
val colindextext : _ string_attr
val colspan : int to_attr
val controls : _ string_attr
val current : [ `page | `step | `location | `date | `time | `true_ ] to_attr
val describedby : _ string_attr
val description : _ string_attr
val details : _ string_attr
val disabled : attr
val errormessage : _ string_attr
val expanded : bool to_attr
val flowto : _ string_attr
val haspopup : [ `true_ | `menu | `listbox | `tree | `grid | `dialog ] to_attr
val hidden : bool to_attr
val invalid : [ `grammar | `spelling | `true_ ] to_attr
val keyshortcuts : _ string_attr
val label : _ string_attr
val labelledby : _ string_attr
val level : int to_attr
val live : [ `assertive | `polite ] to_attr
val modal : attr
val multiline : attr
val multiselectable : attr
val orientation : [ `horizontal | `vertical ] to_attr
val owns : _ string_attr
val placeholder : _ string_attr
val posinset : int to_attr
val pressed : [ `false_ | `mixed | `true_ ] to_attr
val readonly : attr
val relevant : [ `additions | `all | `removals | `text ] to_attr
val required : attr
val roledescription : _ string_attr
val rowcount : int to_attr
val rowindex : int to_attr
val rowindextext : _ string_attr
val rowspan : int to_attr
val selected : bool to_attr
val setsize : int to_attr
val sort : [ `ascending | `descending | `other ] to_attr
val valuemax : float to_attr
val valuemin : float to_attr
val valuenow : float to_attr
val valuetext : _ string_attr
diff --git a/dream-html/Dream_html/HTML/index.html b/dream-html/Dream_html/HTML/index.html index d8697ae..ae92ff7 100644 --- a/dream-html/Dream_html/HTML/index.html +++ b/dream-html/Dream_html/HTML/index.html @@ -1,7 +1,8 @@ -HTML (dream-html.Dream_html.HTML)

Module Dream_html.HTML

All standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.

Attributes

Standard, most non-deprecated attributes from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes. Where an attribute name conflicts with an OCaml keyword, the name is suffixed with _. Most attributes are constructed by passing in a value of some type.

All string-valued attributes allow formatting (interpolation):

div [id "section-%d" section_id] []

Or plain strings:

p [id "toast"] []

Most boolean attributes are plain values and don't need to be constructed with function calls:

input [required]

However, boolean attributes which may be inherited and toggled on/off in children, are constructed by passing in a value:

div
-  [contenteditable true]
-  [p [] [txt "Edit me!"]; p [contenteditable false] [txt "Can't edit me!"]]

Enumerated attributes accept specific values:

input [inputmode `tel]
type enctype = [
  1. | `urlencoded
  2. | `formdata
  3. | `text_plain
]
type method_ = [
  1. | `GET
  2. | `POST
  3. | `dialog
    (*
    • since 2.1.0
    *)
]
val null_ : attr

An attribute that will not be rendered in the markup. Useful for conditional logic where you sometimes want to render an attribute and sometimes not.

p [if should_show then null_ else style_ "display:none"] [txt "Show and tell"]
val accept : _ string_attr
val accept_charset : _ string_attr
val accesskey : _ string_attr
val action : _ string_attr
val align : _ string_attr
  • deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
val allow : _ string_attr
val alt : _ string_attr
val async : attr
val autocapitalize : +HTML (dream-html.Dream_html.HTML)

Module Dream_html.HTML

All standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.

Attributes

Standard, most non-deprecated attributes from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes. Where an attribute name conflicts with an OCaml keyword, the name is suffixed with _. Most attributes are constructed by passing in a value of some type.

All string-valued attributes allow formatting (interpolation):

div [id "section-%d" section_id] []

Or plain strings:

p [id "toast"] []

Most boolean attributes are plain values and don't need to be constructed with function calls:

input [required]

However, boolean attributes which may be inherited and toggled on/off in children, are constructed by passing in a value:

div [contenteditable true] [
+  p [] [txt "Edit me!"];
+  p [contenteditable false] [txt "Can't edit me!"];
+]

Enumerated attributes accept specific values:

input [inputmode `tel]
  • since 1.0.0.
type enctype = [
  1. | `urlencoded
  2. | `formdata
  3. | `text_plain
]
type method_ = [
  1. | `GET
  2. | `POST
  3. | `dialog
    (*
    • since 2.1.0
    *)
]
val null_ : attr

An attribute that will not be rendered in the markup. Useful for conditional logic where you sometimes want to render an attribute and sometimes not.

p [if should_show then null_ else style_ "display:none"] [txt "Show and tell"]
val accept : _ string_attr
val accept_charset : _ string_attr
val accesskey : _ string_attr
val action : _ string_attr
val align : _ string_attr
  • deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
val allow : _ string_attr
val alt : _ string_attr
val async : attr
val autocapitalize : [< `off | `none | `on | `sentences | `words | `characters ] to_attr
val autocomplete : [< `off | `on @@ -149,13 +150,12 @@ | `tree | `treegrid | `treeitem ] - to_attr
  • since 3.0.0
val rows : int to_attr
val rowspan : int to_attr
val sandbox : _ string_attr
val scope : _ string_attr
val selected : attr
val shape : _ string_attr
val sizes : _ string_attr
val slot_ : _ string_attr
val span_ : int to_attr
val spellcheck : bool to_attr
val src : _ string_attr
val srcdoc : _ string_attr
val srclang : _ string_attr
val srcset : _ string_attr
val start : int to_attr
val step : _ string_attr
val style_ : _ string_attr

Note that the value of this attribute is not escaped.

val tabindex : int to_attr
val target : _ string_attr
val title_ : _ string_attr
val translate : [< `yes | `no ] to_attr
val type_ : _ string_attr

Note: this can't be restricted to just the allowed values for <input type>, because it's used on other elements e.g. <link type>.

val usemap : _ string_attr
val value : _ string_attr
val width : _ string_attr
val wrap : [< `hard | `soft ] to_attr

Tags

HTML tags. Most (standard tags) are constructed by passing a list of attributes and a list of children:

div [id "my-div"] [p [] [txt "Hello"]]

Some (void elements) are constructed only with a list of attributes:

input [required; type_ "email"; name "email-addr"]

Finally, a few (text elements) are constructed with a list of attributes and a single text child:

title [] "Document title"
+    to_attr
  • since 3.0.0
val rows : int to_attr
val rowspan : int to_attr
val sandbox : _ string_attr
val scope : _ string_attr
val selected : attr
val shape : _ string_attr
val sizes : _ string_attr
val slot_ : _ string_attr
val span_ : int to_attr
val spellcheck : bool to_attr
val src : _ string_attr
val srcdoc : _ string_attr
val srclang : _ string_attr
val srcset : _ string_attr
val start : int to_attr
val step : _ string_attr
val style_ : _ string_attr

Note that the value of this attribute is not escaped.

val tabindex : int to_attr
val target : _ string_attr
val title_ : _ string_attr
val translate : [< `yes | `no ] to_attr
val type_ : _ string_attr

Note: this can't be restricted to just the allowed values for <input type>, because it's used in other elements e.g. <link type>.

val usemap : _ string_attr
val value : _ string_attr
val width : _ string_attr
val wrap : [< `hard | `soft ] to_attr

Tags

HTML tags. Most (standard tags) are constructed by passing a list of attributes and a list of children:

div [id "my-div"] [p [] [txt "Hello"]]

Some (void elements) are constructed only with a list of attributes:

input [required; type_ "email"; name "email-addr"]

Finally, a few (text elements) are constructed with a list of attributes and a single format string child:

title [] "Document title"
 
 title [] "My App ・ %s" page_name
 
-script [] {|alert('Careful, this is not escaped :-)');|}
val null : node list -> node

A tag that will not be rendered in the markup. Useful for containing a bunch of child nodes inside a single node without having to litter the DOM with an actual node. Also may be called 'splicing'.

null
-  [ p [] [txt "This paragraph."];
-    p [] [txt "And this paragraph."];
-    p []
-      [txt "Are spliced directly into the document without a containing node."]
-  ]
val a : std_tag
val address : std_tag
val area : void_tag
val abbr : std_tag
val article : std_tag
val aside : std_tag
val audio : std_tag
val b : std_tag
val base : void_tag
val bdi : std_tag
val bdo : std_tag
val blockquote : std_tag
val body : std_tag
val br : void_tag
val button : std_tag
val canvas : std_tag
val caption : std_tag
val cite : std_tag
val code : std_tag
val col : void_tag
val colgroup : std_tag
val data : std_tag
val datalist : std_tag
val dd : std_tag
val del : std_tag
val details : std_tag
val dfn : std_tag
val dialog : std_tag
val div : std_tag
val dl : std_tag
val dt : std_tag
val em : std_tag
val embed : void_tag
val fieldset : std_tag
val figcaption : std_tag
val figure : std_tag
val form : std_tag
val h1 : std_tag
val h2 : std_tag
val h3 : std_tag
val h4 : std_tag
val h5 : std_tag
val h6 : std_tag
val head : std_tag
val header : std_tag
val hgroup : std_tag
val hr : void_tag
val html : std_tag

A <!DOCTYPE html> declaration is automatically prefixed when this tag is printed.

val i : std_tag
val iframe : std_tag
val img : void_tag
val input : void_tag
val ins : std_tag
val kbd : std_tag
val label : std_tag
val legend : std_tag
val li : std_tag
val main : std_tag
val map : std_tag
val mark : std_tag
val menu : std_tag
val meta : void_tag
val meter : std_tag
val nav : std_tag
val noscript : std_tag
val object_ : std_tag
val ol : std_tag
val optgroup : std_tag
val option : _ text_tag
val output : std_tag
val p : std_tag
val picture : std_tag
val pre : std_tag
val progress : std_tag
val q : std_tag
val rp : std_tag
val rt : std_tag
val ruby : std_tag
val s : std_tag
val samp : std_tag
val script : _ text_tag

Note that the content of this tag is not escaped.

val section : std_tag
val select : std_tag
val slot : std_tag
val small : std_tag
val source : void_tag
val span : std_tag
val strong : std_tag
val style : _ text_tag

Note that the content of this tag is not escaped.

val sub : std_tag
val summary : std_tag
val sup : std_tag
val table : std_tag
val tbody : std_tag
val td : std_tag
val template : std_tag
val textarea : _ text_tag
val tfoot : std_tag
val th : std_tag
val thead : std_tag
val time : std_tag
val title : _ text_tag
val tr : std_tag
val track : void_tag
val u : std_tag
val ul : std_tag
val var : std_tag
val video : std_tag
val wbr : void_tag
+script [] {|alert('Careful, this is not escaped :-)');|}
val null : node list -> node

A tag that will not be rendered in the markup. Useful for containing a bunch of child nodes inside a single node without having to litter the DOM with an actual node. Also may be called 'splicing'.

null [
+  p [] [txt "This paragraph."];
+  p [] [txt "And this paragraph."];
+  p [] [txt "Are spliced directly into the document without a containing node."];
+]

Also useful for constructing a completely empty node that is erased when printing:

null []
val a : std_tag
val address : std_tag
val area : void_tag
val abbr : std_tag
val article : std_tag
val aside : std_tag
val audio : std_tag
val b : std_tag
val base : void_tag
val bdi : std_tag
val bdo : std_tag
val blockquote : std_tag
val body : std_tag
val br : void_tag
val button : std_tag
val canvas : std_tag
val caption : std_tag
val cite : std_tag
val code : std_tag
val col : void_tag
val colgroup : std_tag
val data : std_tag
val datalist : std_tag
val dd : std_tag
val del : std_tag
val details : std_tag
val dfn : std_tag
val dialog : std_tag
val div : std_tag
val dl : std_tag
val dt : std_tag
val em : std_tag
val embed : void_tag
val fieldset : std_tag
val figcaption : std_tag
val figure : std_tag
val form : std_tag
val h1 : std_tag
val h2 : std_tag
val h3 : std_tag
val h4 : std_tag
val h5 : std_tag
val h6 : std_tag
val head : std_tag
val header : std_tag
val hgroup : std_tag
val hr : void_tag
val html : std_tag

A <!DOCTYPE html> declaration is automatically prefixed when this tag is printed.

val i : std_tag
val iframe : std_tag
val img : void_tag
val input : void_tag
val ins : std_tag
val kbd : std_tag
val label : std_tag
val legend : std_tag
val li : std_tag
val main : std_tag
val map : std_tag
val mark : std_tag
val menu : std_tag
val meta : void_tag
val meter : std_tag
val nav : std_tag
val noscript : std_tag
val object_ : std_tag
val ol : std_tag
val optgroup : std_tag
val option : _ text_tag
val output : std_tag
val p : std_tag
val picture : std_tag
val pre : std_tag
val progress : std_tag
val q : std_tag
val rp : std_tag
val rt : std_tag
val ruby : std_tag
val s : std_tag
val samp : std_tag
val script : _ text_tag

Note that the content of this tag is not escaped.

val section : std_tag
val select : std_tag
val slot : std_tag
val small : std_tag
val source : void_tag
val span : std_tag
val strong : std_tag
val style : _ text_tag

Note that the content of this tag is not escaped.

val sub : std_tag
val summary : std_tag
val sup : std_tag
val table : std_tag
val tbody : std_tag
val td : std_tag
val template : std_tag
val textarea : _ text_tag
val tfoot : std_tag
val th : std_tag
val thead : std_tag
val time : std_tag
val title : _ text_tag
val tr : std_tag
val track : void_tag
val u : std_tag
val ul : std_tag
val var : std_tag
val video : std_tag
val wbr : void_tag
diff --git a/dream-html/Dream_html/Hx/index.html b/dream-html/Dream_html/Hx/index.html index d40e2ba..15e01db 100644 --- a/dream-html/Dream_html/Hx/index.html +++ b/dream-html/Dream_html/Hx/index.html @@ -1,2 +1,2 @@ -Hx (dream-html.Dream_html.Hx)

Module Dream_html.Hx

htmx support https://htmx.org/reference/

val __ : _ string_attr

This attribute serves as the _ attribute, which is used by Hyperscript. Note that the value of this attribute is not escaped.

  • since 0.1.0.
val boost : bool to_attr
val confirm : _ string_attr
val delete : _ string_attr
val disable : attr
val disinherit : _ string_attr
val encoding_formdata : attr

Hardcoding of the hx-encoding attribute to multipart/form-data.

val ext : _ string_attr
val get : _ string_attr
val headers : _ string_attr
val history_false : attr

Hardcoding of the hx-history attribute to false.

val history_elt : attr
val include_ : _ string_attr
val indicator : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val on : _ string_attr

Note that the value of this attribute is not escaped.

  • deprecated See https://htmx.org/attributes/hx-on/#hx-on-deprecated
val on_ : event:string -> _ string_attr

The hx-on:* set of attributes, where * represents DOM events: https://htmx.org/attributes/hx-on/.

Note that the value of this attribute is not escaped.

  • since 2.1.0.
val params : _ string_attr
val patch : _ string_attr
val post : _ string_attr
val preload : attr
val preserve : attr
val prompt : _ string_attr
val push_url : _ string_attr
val put : _ string_attr
val replace_url : _ string_attr
val request : _ string_attr
val select : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val select_oob : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val sse_connect : _ string_attr
val sse_swap : _ string_attr
val swap : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val swap_oob : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val sync : _ string_attr
val target : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val trigger : _ string_attr

Note that the value of this attribute is not escaped.

val validate : attr
val vals : _ string_attr
val ws_connect : _ string_attr
val ws_send : attr
+Hx (dream-html.Dream_html.Hx)

Module Dream_html.Hx

htmx support https://htmx.org/reference/

val __ : _ string_attr

This attribute serves as the _ attribute, which is used by Hyperscript. Note that the value of this attribute is not escaped.

  • since 0.1.0.
val boost : bool to_attr
val confirm : _ string_attr
val delete : _ string_attr
val disable : attr
val disinherit : _ string_attr
val encoding_formdata : attr

Hardcoding of the hx-encoding attribute to multipart/form-data.

val ext : _ string_attr
val get : _ string_attr
val headers : _ string_attr
val history_false : attr

Hardcoding of the hx-history attribute to false.

val history_elt : attr
val include_ : _ string_attr
val indicator : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val on : _ string_attr

Note that the value of this attribute is not escaped.

  • deprecated See https://htmx.org/attributes/hx-on/#hx-on-deprecated
val on_ : event:string -> _ string_attr

The hx-on:* set of attributes, where * represents DOM events: https://htmx.org/attributes/hx-on/.

Note that the value of this attribute is not escaped.

  • since 2.1.0.
val params : _ string_attr
val patch : _ string_attr
val post : _ string_attr
val preload : attr
val preserve : attr
val prompt : _ string_attr
val push_url : _ string_attr
val put : _ string_attr
val replace_url : _ string_attr
val request : _ string_attr
val select : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val select_oob : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val sse_connect : _ string_attr
val sse_swap : _ string_attr
val swap : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val swap_oob : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val sync : _ string_attr
val target : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val trigger : _ string_attr

Note that the value of this attribute is not escaped.

val validate : attr
val vals : _ string_attr
val ws_connect : _ string_attr
val ws_send : attr
diff --git a/dream-html/Dream_html/Livereload/index.html b/dream-html/Dream_html/Livereload/index.html index 61d4390..b24b4d2 100644 --- a/dream-html/Dream_html/Livereload/index.html +++ b/dream-html/Dream_html/Livereload/index.html @@ -1,5 +1,5 @@ -Livereload (dream-html.Dream_html.Livereload)

Module Dream_html.Livereload

Live reload script injection and handling. Adapted from Dream.livereload middleware. This version is not a middleware so it's not as plug-and-play as that, but on the other hand it's much simpler to implement because it uses type-safe dream-html nodes rather than parsing and printing raw HTML. See below for the 3-step process to use it.

This module is adapted from Dream, released under the MIT license. For details, visit https://github.com/aantron/dream.

Copyright 2021-2023 Thibaut Mattio, Anton Bachin.

val route : Dream.route

(1) Put this in your top-level router:

let () = Dream.run
+Livereload (dream-html.Dream_html.Livereload)

Module Dream_html.Livereload

Live reload script injection and handling. Adapted from Dream.livereload middleware. This version is not a middleware so it's not as plug-and-play as that, but on the other hand it's much simpler to implement because it uses type-safe dream-html nodes rather than parsing and printing raw HTML. See below for the 3-step process to use it.

This module is adapted from Dream, released under the MIT license. For details, visit https://github.com/aantron/dream.

Copyright 2021-2023 Thibaut Mattio, Anton Bachin.

  • since 3.4.0.
val route : Dream.route

(1) Put this in your top-level router:

let () = Dream.run
   @@ Dream.logger
   @@ Dream.router [
     Dream_html.Livereload.route;
@@ -7,4 +7,4 @@
 ]
val script : node

(2) Put this inside your head:

head [] [
   Livereload.script;
   (* ... *)
-]

(3) And run the server with environment variable ENV=dev.

⚠️ If this env var is not set, then livereload is turned off. This means that the route will respond with 404 status and the script will be omitted from the rendered HTML.

+]

(3) And run the server with environment variable LIVERELOAD=1.

⚠️ If this env var is not set, then livereload is turned off. This means that the route will respond with 404 status and the script will be omitted from the rendered HTML.

diff --git a/dream-html/Dream_html/MathML/index.html b/dream-html/Dream_html/MathML/index.html index 2e042a1..4e13382 100644 --- a/dream-html/Dream_html/MathML/index.html +++ b/dream-html/Dream_html/MathML/index.html @@ -1,2 +1,2 @@ -MathML (dream-html.Dream_html.MathML)

Module Dream_html.MathML

val accent : bool to_attr
val accentunder : bool to_attr
val columnspan : int to_attr
val depth : _ string_attr
val dir : [ `ltr | `rtl ] to_attr
val display_block : attr

See https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#display. display=inline is the default, so there is no need to bind its value.

val displaystyle : bool to_attr
val fence : bool to_attr
val height : _ string_attr
val largeop : bool to_attr
val linethickness : _ string_attr
val lspace : _ string_attr
val mathvariant : _ string_attr
val maxsize : _ string_attr
val minsize : _ string_attr
val movablelimits : bool to_attr
val rowspan : int to_attr
val rspace : _ string_attr
val scriptlevel : _ string_attr
val separator : bool to_attr
val stretchy : bool to_attr
val symmetric : bool to_attr
val voffset : _ string_attr
val xmlns : attr
val annotation : std_tag
val annotation_xml : std_tag
val math : std_tag
val merror : std_tag
val mfrac : std_tag
val mi : std_tag
val mmultiscripts : std_tag
val mn : std_tag
val mo : std_tag
val mover : std_tag
val mpadded : std_tag
val mphantom : std_tag
val mroot : std_tag
val mrow : std_tag
val ms : std_tag
val mspace : std_tag
val msqrt : std_tag
val mstyle : std_tag
val msub : std_tag
val msubsup : std_tag
val msup : std_tag
val mtable : std_tag
val mtd : std_tag
val mtext : std_tag
val mtr : std_tag
val munder : std_tag
val munderover : std_tag
val semantics : std_tag
+MathML (dream-html.Dream_html.MathML)

Module Dream_html.MathML

val accent : bool to_attr
val accentunder : bool to_attr
val columnspan : int to_attr
val depth : _ string_attr
val dir : [ `ltr | `rtl ] to_attr
val display_block : attr

See https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#display. display=inline is the default, so there is no need to bind its value.

val displaystyle : bool to_attr
val fence : bool to_attr
val height : _ string_attr
val largeop : bool to_attr
val linethickness : _ string_attr
val lspace : _ string_attr
val mathvariant : _ string_attr
val maxsize : _ string_attr
val minsize : _ string_attr
val movablelimits : bool to_attr
val rowspan : int to_attr
val rspace : _ string_attr
val scriptlevel : _ string_attr
val separator : bool to_attr
val stretchy : bool to_attr
val symmetric : bool to_attr
val voffset : _ string_attr
val xmlns : attr
val annotation : std_tag
val annotation_xml : std_tag
val math : std_tag
val merror : std_tag
val mfrac : std_tag
val mi : std_tag
val mmultiscripts : std_tag
val mn : std_tag
val mo : std_tag
val mover : std_tag
val mpadded : std_tag
val mphantom : std_tag
val mroot : std_tag
val mrow : std_tag
val ms : std_tag
val mspace : std_tag
val msqrt : std_tag
val mstyle : std_tag
val msub : std_tag
val msubsup : std_tag
val msup : std_tag
val mtable : std_tag
val mtd : std_tag
val mtext : std_tag
val mtr : std_tag
val munder : std_tag
val munderover : std_tag
val semantics : std_tag
diff --git a/dream-html/Dream_html/SVG/index.html b/dream-html/Dream_html/SVG/index.html index f828262..d6f0f61 100644 --- a/dream-html/Dream_html/SVG/index.html +++ b/dream-html/Dream_html/SVG/index.html @@ -1,3 +1,3 @@ -SVG (dream-html.Dream_html.SVG)

Module Dream_html.SVG

val d : _ string_attr
val fill : _ string_attr
val stroke : _ string_attr
val stroke_linecap : [< `butt | `round | `square ] to_attr
val stroke_linejoin : +SVG (dream-html.Dream_html.SVG)

Module Dream_html.SVG

  • since 1.1.0.
val d : _ string_attr
val fill : _ string_attr
val stroke : _ string_attr
val stroke_linecap : [< `butt | `round | `square ] to_attr
val stroke_linejoin : [< `arcs | `bevel | `miter | `miter_clip | `round ] to_attr
val stroke_width : _ string_attr
val viewbox : min_x:int -> min_y:int -> width:int -> height:int -> attr
val xmlns : attr
val path : std_tag
val svg : std_tag
diff --git a/dream-html/Dream_html/index.html b/dream-html/Dream_html/index.html index caa10cc..12b3162 100644 --- a/dream-html/Dream_html/index.html +++ b/dream-html/Dream_html/index.html @@ -1,17 +1,14 @@ -Dream_html (dream-html.Dream_html)

Module Dream_html

Constructing HTML. Detailed explanation in https://github.com/yawaramin/dream-html.

Let's adapt the example from the Dream home page:

let hello who =
-  let open Dream_html in
-  let open HTML in
-  html [] [
-    body [] [
-      h1 [] [txt "Hello, %s!" who];
-    ];
-  ]
+Dream_html (dream-html.Dream_html)

Module Dream_html

include module type of Pure_html

Core types

These are the types of the final values which get rendered.

type attr

E.g. id="toast".

type node

Either a tag, a comment, or text data in the markup.

Output

val to_string : node -> string
val to_xml : node -> string

Same as to_string but render void tags as XML-style self-closing tags.

  • since 3.3.0.
val pp : Stdlib.Format.formatter -> node -> unit
val pp_xml : Stdlib.Format.formatter -> node -> unit

Same as pp but render void tags as XML-style self-closing tags.

  • since 3.3.0.

Constructing nodes and attributes

type 'a to_attr = 'a -> attr

Attributes can be created from typed values.

type 'a string_attr = ('a, unit, string, attr) Stdlib.format4 -> 'a

Special handling for string-value attributes so they can use format strings i.e. string interpolation.

type std_tag = attr list -> node list -> node

A 'standard' tag with attributes and children.

type void_tag = attr list -> node
type 'a text_tag = attr list -> ('a, unit, string, node) Stdlib.format4 -> 'a

Tags which can have attributes but can contain only text. The text can be formatted.

val attr : string -> attr

attr name is a new attribute which does not carry any payload. E.g.

let required = attr "required"
  • since 0.1.0.
val string_attr : string -> ?raw:bool -> _ string_attr

string_attr name fmt is a new string-valued attribute which allows formatting i.e. string interpolation of the value. Note, the fmt argument is required due to the value restriction.

val uri_attr : string -> _ string_attr

Convenience for attributes whose values should be URIs. Takes care of both URI-encoding and attribute escaping, as recommended in https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#common-mistake.

Examples

a [href "/blog?tags=iamsafe\"></a><script>alert('Pwned')</script>"] [txt "Tags: tag1 | tag2"]
+==>
+<a href="/blog?tags=iamsafe%22%3E%3C/a%3E%3Cscript%3Ealert('Pwned')%3C/script%3E">Tags: tag1 | tag2</a>
 
-let () =
-  Dream.run
-  @@ Dream.logger
-  @@ Dream.router [Dream.get "/" (fun _ -> Dream_html.respond (hello "world"))]

More examples shown below.

Note that the version of this library installed on your device may have outdated documentation strings. To view the latest documentation, please visit the repository page.

Core types

These are the types of the final values which get rendered.

type attr

E.g. id="toast".

type node

Either a tag, a comment, or text data in the markup.

Output

val to_string : node -> string
val to_xml : node -> string

Same as to_string but render void tags as XML-style self-closing tags.

  • since 3.3.0.
val pp : Stdlib.Format.formatter -> node -> unit
val pp_xml : Stdlib.Format.formatter -> node -> unit

Same as pp but render void tags as XML-style self-closing tags.

  • since 3.3.0.
val respond : +a [href "/foo?a=1&b=2 3&c=4<5&d=6>5"] [txt "Test"] +==> +<a href="/foo?a=1&amp;b=2%203&amp;c=4%3C5&amp;d=6%3E5">Test</a>
val bool_attr : string -> bool to_attr
val float_attr : string -> float to_attr
val int_attr : string -> int to_attr
val std_tag : string -> std_tag
val void_tag : string -> void_tag
val text_tag : string -> ?raw:bool -> _ text_tag

Build a tag which can contain only text.

val txt : ?raw:bool -> ('a, unit, string, node) Stdlib.format4 -> 'a

A text node inside the DOM e.g. the 'hi' in <b>hi</b>. Allows string interpolation using the same formatting features as Printf.sprintf:

b [] [txt "Hello, %s!" name]

Or without interpolation:

b [] [txt "Bold of you."]

HTML-escapes the text value. You can use the ~raw param to bypass escaping:

let user_input = "<script>alert('I like HTML injection')</script>" in
+txt ~raw:true "%s" user_input
val comment : string -> node

A comment that will be embedded in the rendered HTML, i.e. <!-- comment -->. The text is HTML-escaped.

Accessors for tags

val (+@) : node -> attr -> node

Add an attribute to a tag.

let toast msg = p [id "toast"] [txt "%s" msg]
+let toast_oob = toast "ok." +@ Hx.swap_oob "true"
  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • since 0.0.3.
val (-@) : node -> string -> node

Remove an attribute from a tag.

  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • since 0.0.3.
val (.@[]) : node -> string -> string

Get the value of an existing attribute.

let toast = p [id "toast"] [txt "OK."]
+let toast_id = toast.@["id"]
  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • raises Not_found

    if the tag does not have the given attribute.

  • since 0.0.3.
val is_null : node -> bool

Get whether a node is null (empty) or not. Useful for conditional rendering of UIs when you are passed in a node and you don't know if it's empty or not.

  • since 1.2.0.
val is_null_ : attr -> bool

Get whether an attribute is null (empty) or not.

  • since 1.2.0.

Standard attributes and tags

module HTML : sig ... end

All standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.

module SVG : sig ... end
module MathML : sig ... end

ARIA support

htmx support

module Hx : sig ... end

Output

val respond : ?status:[< Dream.status ] -> ?code:int -> ?headers:(string * string) list -> @@ -21,15 +18,6 @@ ?end_of_message:[< Dream.end_of_message ] -> Dream.websocket -> node -> - unit Dream.promise

Type-safe wrapper for Dream.send.

  • since 3.2.0.
val set_body : Dream.response -> node -> unit

Type-safe wrapper for Dream.set_body. Sets the body to the given node and sets the Content-Type header to text/html.

val write : Dream.stream -> node -> unit Dream.promise

Type-safe wrapper for Dream.write.

Constructing nodes and attributes

type 'a to_attr = 'a -> attr

Attributes can be created from typed values.

type 'a string_attr = ('a, unit, string, attr) Stdlib.format4 -> 'a

Special handling for string-value attributes so they can use format strings i.e. string interpolation.

type std_tag = attr list -> node list -> node

A 'standard' tag with attributes and children.

type void_tag = attr list -> node
type 'a text_tag = attr list -> ('a, unit, string, node) Stdlib.format4 -> 'a

Tags which can have attributes but can contain only text. The text can be formatted.

val attr : string -> attr

attr name is a new attribute which does not carry any payload. E.g.

let required = attr "required"
  • since 0.1.0.
val string_attr : string -> ?raw:bool -> _ string_attr

string_attr name fmt is a new string-valued attribute which allows formatting i.e. string interpolation of the value. Note, the fmt argument is required due to the value restriction.

val uri_attr : string -> _ string_attr

Convenience for attributes whose values should be URIs. Takes care of both URI-encoding and attribute escaping, as recommended in https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#common-mistake.

Examples

a [href "/blog?tags=iamsafe\"></a><script>alert('Pwned')</script>"] [txt "Tags: tag1 | tag2"]
-==>
-<a href="/blog?tags=iamsafe%22%3E%3C/a%3E%3Cscript%3Ealert('Pwned')%3C/script%3E">Tags: tag1 | tag2</a>
-
-a [href "/foo?a=1&b=2 3&c=4<5&d=6>5"] [txt "Test"]
-==>
-<a href="/foo?a=1&amp;b=2%203&amp;c=4%3C5&amp;d=6%3E5">Test</a>
val bool_attr : string -> bool to_attr
val float_attr : string -> float to_attr
val int_attr : string -> int to_attr
val std_tag : string -> std_tag
val void_tag : string -> void_tag
val text_tag : string -> ?raw:bool -> _ text_tag

Build a tag which can contain only text.

val txt : ?raw:bool -> ('a, unit, string, node) Stdlib.format4 -> 'a

A text node inside the DOM e.g. the 'hi' in <b>hi</b>. Allows string interpolation using the same formatting features as Printf.sprintf:

b [] [txt "Hello, %s!" name]

Or without interpolation:

b [] [txt "Bold of you."]

HTML-escapes the text value. You can use the ~raw param to bypass escaping:

let user_input = "<script>alert('I like HTML injection')</script>" in
-txt ~raw:true "%s" user_input
val comment : string -> node

A comment that will be embedded in the rendered HTML, i.e. <!-- comment -->. The text is HTML-escaped.

val csrf_tag : Dream.request -> node

Convenience to add a CSRF token generated by Dream into your form. Type-safe wrapper for Dream.csrf_tag.

form
+  unit Dream.promise

Type-safe wrapper for Dream.send.

  • since 3.2.0.
val set_body : Dream.response -> node -> unit

Type-safe wrapper for Dream.set_body. Sets the body to the given node and sets the Content-Type header to text/html.

val write : Dream.stream -> node -> unit Dream.promise

Type-safe wrapper for Dream.write.

val csrf_tag : Dream.request -> node

Convenience to add a CSRF token generated by Dream into your form. Type-safe wrapper for Dream.csrf_tag.

form
   [action "/foo"]
-  [csrf_tag req; input [name "bar"]; input [type_ "submit"]]

Accessors for tags

val (+@) : node -> attr -> node

Add an attribute to a tag.

let toast msg = p [id "toast"] [txt "%s" msg]
-let toast_oob = toast "ok." +@ Hx.swap_oob "true"
  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • since 0.0.3.
val (-@) : node -> string -> node

Remove an attribute from a tag.

  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • since 0.0.3.
val (.@[]) : node -> string -> string

Get the value of an existing attribute.

let toast = p [id "toast"] [txt "OK."]
-let toast_id = toast.@["id"]
  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • raises Not_found

    if the tag does not have the given attribute.

  • since 0.0.3.
val is_null : node -> bool

Get whether a node is null (empty) or not. Useful for conditional rendering of UIs when you are passed in a node and you don't know if it's empty or not.

  • since 1.2.0.
val is_null_ : attr -> bool

Get whether an attribute is null (empty) or not.

  • since 1.2.0.

Standard attributes and tags

module HTML : sig ... end

All standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.

module SVG : sig ... end
module MathML : sig ... end

ARIA support

htmx support

module Hx : sig ... end

Live reload support

module Livereload : sig ... end

Live reload script injection and handling. Adapted from Dream.livereload middleware. This version is not a middleware so it's not as plug-and-play as that, but on the other hand it's much simpler to implement because it uses type-safe dream-html nodes rather than parsing and printing raw HTML. See below for the 3-step process to use it.

+ [csrf_tag req; input [name "bar"]; input [type_ "submit"]]

Live reload support

module Livereload : sig ... end

Live reload script injection and handling. Adapted from Dream.livereload middleware. This version is not a middleware so it's not as plug-and-play as that, but on the other hand it's much simpler to implement because it uses type-safe dream-html nodes rather than parsing and printing raw HTML. See below for the 3-step process to use it.

diff --git a/dream-html/index.html b/dream-html/index.html index f717afa..b4ff5c1 100644 --- a/dream-html/index.html +++ b/dream-html/index.html @@ -1,2 +1,2 @@ -index (dream-html.index)

dream-html index

Library dream-html

The entry point of this library is the module: Dream_html.

+index (dream-html.index)

dream-html index

Library dream-html

The entry point of this library is the module: Dream_html.

diff --git a/index.html b/index.html index 1614e60..c7f1858 100644 --- a/index.html +++ b/index.html @@ -1,19 +1,304 @@ - + + + + dream-html - Render HTML, SVG, MathML, htmx markup from your OCaml Dream backend server + + + + + + + + + + + + + + +
+ +
+
+
+
+ +
+

Renders OCaml:

+
open Dream_html
+open HTML
+
html [lang "en"] [
+  head [] [
+    title [] "My page";
+  ];
+  body [] [
+    h1 [] [txt "My text"];
+  ];
+]
+
+
+

To HTML/SVG/MathML (try it):

+ + +
+
+
+
+

Install & use

+ +

See the readme.

+
+
+ + + \ No newline at end of file diff --git a/odoc.support/odoc.css b/odoc.support/odoc.css index c23517b..71148de 100644 --- a/odoc.support/odoc.css +++ b/odoc.support/odoc.css @@ -1,7 +1,7 @@ @charset "UTF-8"; /* Copyright (c) 2016 The odoc contributors. All rights reserved. Distributed under the ISC license, see terms at the end of the file. - odoc 2.4.1 */ + odoc 2.4.2 */ /* Fonts */ /* noticia-text-regular - latin */ diff --git a/pure-html/Pure_html/Aria/index.html b/pure-html/Pure_html/Aria/index.html new file mode 100644 index 0000000..54ebf1c --- /dev/null +++ b/pure-html/Pure_html/Aria/index.html @@ -0,0 +1,2 @@ + +Aria (pure-html.Pure_html.Aria)

Module Pure_html.Aria

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/

  • since 3.0.0.
val activedescendant : _ string_attr
val atomic : attr
val autocomplete : [ `inline | `list | `both ] to_attr
val braillelabel : _ string_attr
val brailleroledescription : _ string_attr
val busy : attr
val checked : [ `false_ | `true_ | `mixed ] to_attr
val colcount : int to_attr
val colindextext : _ string_attr
val colspan : int to_attr
val controls : _ string_attr
val current : [ `page | `step | `location | `date | `time | `true_ ] to_attr
val describedby : _ string_attr
val description : _ string_attr
val details : _ string_attr
val disabled : attr
val errormessage : _ string_attr
val expanded : bool to_attr
val flowto : _ string_attr
val haspopup : [ `true_ | `menu | `listbox | `tree | `grid | `dialog ] to_attr
val hidden : bool to_attr
val invalid : [ `grammar | `spelling | `true_ ] to_attr
val keyshortcuts : _ string_attr
val label : _ string_attr
val labelledby : _ string_attr
val level : int to_attr
val live : [ `assertive | `polite ] to_attr
val modal : attr
val multiline : attr
val multiselectable : attr
val orientation : [ `horizontal | `vertical ] to_attr
val owns : _ string_attr
val placeholder : _ string_attr
val posinset : int to_attr
val pressed : [ `false_ | `mixed | `true_ ] to_attr
val readonly : attr
val relevant : [ `additions | `all | `removals | `text ] to_attr
val required : attr
val roledescription : _ string_attr
val rowcount : int to_attr
val rowindex : int to_attr
val rowindextext : _ string_attr
val rowspan : int to_attr
val selected : bool to_attr
val setsize : int to_attr
val sort : [ `ascending | `descending | `other ] to_attr
val valuemax : float to_attr
val valuemin : float to_attr
val valuenow : float to_attr
val valuetext : _ string_attr
diff --git a/pure-html/Pure_html/HTML/index.html b/pure-html/Pure_html/HTML/index.html new file mode 100644 index 0000000..998fede --- /dev/null +++ b/pure-html/Pure_html/HTML/index.html @@ -0,0 +1,161 @@ + +HTML (pure-html.Pure_html.HTML)

Module Pure_html.HTML

All standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.

Attributes

Standard, most non-deprecated attributes from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes. Where an attribute name conflicts with an OCaml keyword, the name is suffixed with _. Most attributes are constructed by passing in a value of some type.

All string-valued attributes allow formatting (interpolation):

div [id "section-%d" section_id] []

Or plain strings:

p [id "toast"] []

Most boolean attributes are plain values and don't need to be constructed with function calls:

input [required]

However, boolean attributes which may be inherited and toggled on/off in children, are constructed by passing in a value:

div [contenteditable true] [
+  p [] [txt "Edit me!"];
+  p [contenteditable false] [txt "Can't edit me!"];
+]

Enumerated attributes accept specific values:

input [inputmode `tel]
  • since 1.0.0.
type enctype = [
  1. | `urlencoded
  2. | `formdata
  3. | `text_plain
]
type method_ = [
  1. | `GET
  2. | `POST
  3. | `dialog
    (*
    • since 2.1.0
    *)
]
val null_ : attr

An attribute that will not be rendered in the markup. Useful for conditional logic where you sometimes want to render an attribute and sometimes not.

p [if should_show then null_ else style_ "display:none"] [txt "Show and tell"]
val accept : _ string_attr
val accept_charset : _ string_attr
val accesskey : _ string_attr
val action : _ string_attr
val align : _ string_attr
  • deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes
val allow : _ string_attr
val alt : _ string_attr
val async : attr
val autocapitalize : + [< `off | `none | `on | `sentences | `words | `characters ] to_attr
val autocomplete : + [< `off + | `on + | `name + | `honorific_prefix + | `given_name + | `additional_name + | `honorific_suffix + | `nickname + | `email + | `username + | `new_password + | `current_password + | `one_time_code + | `organization_title + | `organization + | `street_address + | `address_line1 + | `address_line2 + | `address_line3 + | `address_level4 + | `address_level3 + | `address_level2 + | `address_level1 + | `country + | `country_name + | `postal_code + | `cc_name + | `cc_given_name + | `cc_additional_name + | `cc_family_name + | `cc_number + | `cc_exp + | `cc_exp_month + | `cc_exp_year + | `cc_csc + | `cc_type + | `transaction_currency + | `transaction_amount + | `language + | `bday + | `bday_day + | `bday_month + | `bday_year + | `sex + | `tel + | `tel_country_code + | `tel_national + | `tel_area_code + | `tel_local + | `tel_extension + | `impp + | `url + | `photo + | `webauthn ] + to_attr
val autofocus : attr
val autoplay : attr
val buffered : _ string_attr
val capture : [< `user | `environment ] to_attr
val charset : _ string_attr
val checked : attr
val cite_ : _ string_attr
val class_ : _ string_attr
val color : _ string_attr
  • deprecated See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#color
val cols : int to_attr
val colspan : int to_attr
val content : _ string_attr
val contenteditable : bool to_attr
val contextmenu : _ string_attr
val controls : attr
val coords : _ string_attr
val crossorigin : [< `anonymous | `use_credentials ] to_attr
val data_ : _ string_attr
val datetime : _ string_attr
val decoding : [< `sync | `async | `auto ] to_attr
val default : attr
val defer : attr
val dir : [< `ltr | `rtl | `auto ] to_attr
val dirname : _ string_attr
val disabled : attr
val download : _ string_attr
val draggable : attr
val enctype : [< enctype ] to_attr
val fetchpriority : [< `high | `low | `auto ] to_attr
  • since 1.2.0.
val for_ : _ string_attr
val form_ : _ string_attr
val formaction : _ string_attr
val formenctype : [< enctype ] to_attr
val formmethod : [< method_ ] to_attr
val formnovalidate : attr
val formtarget : _ string_attr
val headers : _ string_attr
val height : _ string_attr
val hidden : [< `hidden | `until_found ] to_attr
val high : float to_attr
val href : _ string_attr
val hreflang : _ string_attr
val http_equiv : + [< `content_security_policy + | `content_type + | `default_style + | `x_ua_compatible + | `refresh ] + to_attr
val id : _ string_attr
val integrity : _ string_attr
val inputmode : + [< `none | `text | `decimal | `numeric | `tel | `search | `email | `url ] + to_attr
val ismap : attr
val itemprop : _ string_attr
val kind : + [< `subtitles | `captions | `descriptions | `chapters | `metadata ] to_attr
val label_ : _ string_attr
val lang : _ string_attr
val list : _ string_attr
val loading_lazy : attr

See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#loading. loading=eager is the default so no need for specifically that value.

  • since 3.1.0.
val loop : attr
val low : float to_attr
val max : _ string_attr
val maxlength : int to_attr
val media : _ string_attr
val method_ : [< method_ ] to_attr
val min : _ string_attr
val minlength : int to_attr
val multiple : attr
val muted : attr
val name : _ string_attr
val novalidate : attr
val onblur : _ string_attr

Note that the value of this attribute is not escaped.

val onclick : _ string_attr

Note that the value of this attribute is not escaped.

val open_ : attr
val optimum : float to_attr
val pattern : _ string_attr
val ping : _ string_attr
val placeholder : _ string_attr
val playsinline : attr
val poster : _ string_attr
val preload : [< `none | `metadata | `auto ] to_attr
val readonly : attr
val referrerpolicy : + [< `no_referrer + | `no_referrer_when_downgrade + | `origin + | `origin_when_cross_origin + | `same_origin + | `strict_origin + | `strict_origin_when_cross_origin + | `unsafe_url ] + to_attr
val rel : _ string_attr
val required : attr
val reversed : attr
val role : + [ `alert + | `alertdialog + | `application + | `article + | `banner + | `button + | `cell + | `checkbox + | `columnheader + | `combobox + | `comment + | `complementary + | `contentinfo + | `definition + | `dialog + | `document + | `feed + | `figure + | `form + | `generic + | `grid + | `gridcell + | `group + | `heading + | `img + | `link + | `list + | `listbox + | `listitem + | `log + | `main + | `mark + | `marquee + | `math + | `menu + | `menubar + | `menuitem + | `menuitemcheckbox + | `menuitemradio + | `meter + | `navigation + | `none + | `note + | `option + | `presentation + | `progressbar + | `radio + | `radiogroup + | `region + | `row + | `rowgroup + | `rowheader + | `scrollbar + | `search + | `searchbox + | `separator + | `slider + | `spinbutton + | `status + | `suggestion + | `switch + | `tab + | `table + | `tablist + | `tabpanel + | `term + | `textbox + | `timer + | `toolbar + | `tooltip + | `tree + | `treegrid + | `treeitem ] + to_attr
  • since 3.0.0
val rows : int to_attr
val rowspan : int to_attr
val sandbox : _ string_attr
val scope : _ string_attr
val selected : attr
val shape : _ string_attr
val sizes : _ string_attr
val slot_ : _ string_attr
val span_ : int to_attr
val spellcheck : bool to_attr
val src : _ string_attr
val srcdoc : _ string_attr
val srclang : _ string_attr
val srcset : _ string_attr
val start : int to_attr
val step : _ string_attr
val style_ : _ string_attr

Note that the value of this attribute is not escaped.

val tabindex : int to_attr
val target : _ string_attr
val title_ : _ string_attr
val translate : [< `yes | `no ] to_attr
val type_ : _ string_attr

Note: this can't be restricted to just the allowed values for <input type>, because it's used in other elements e.g. <link type>.

val usemap : _ string_attr
val value : _ string_attr
val width : _ string_attr
val wrap : [< `hard | `soft ] to_attr

Tags

HTML tags. Most (standard tags) are constructed by passing a list of attributes and a list of children:

div [id "my-div"] [p [] [txt "Hello"]]

Some (void elements) are constructed only with a list of attributes:

input [required; type_ "email"; name "email-addr"]

Finally, a few (text elements) are constructed with a list of attributes and a single format string child:

title [] "Document title"
+
+title [] "My App ・ %s" page_name
+
+script [] {|alert('Careful, this is not escaped :-)');|}
val null : node list -> node

A tag that will not be rendered in the markup. Useful for containing a bunch of child nodes inside a single node without having to litter the DOM with an actual node. Also may be called 'splicing'.

null [
+  p [] [txt "This paragraph."];
+  p [] [txt "And this paragraph."];
+  p [] [txt "Are spliced directly into the document without a containing node."];
+]

Also useful for constructing a completely empty node that is erased when printing:

null []
val a : std_tag
val address : std_tag
val area : void_tag
val abbr : std_tag
val article : std_tag
val aside : std_tag
val audio : std_tag
val b : std_tag
val base : void_tag
val bdi : std_tag
val bdo : std_tag
val blockquote : std_tag
val body : std_tag
val br : void_tag
val button : std_tag
val canvas : std_tag
val caption : std_tag
val cite : std_tag
val code : std_tag
val col : void_tag
val colgroup : std_tag
val data : std_tag
val datalist : std_tag
val dd : std_tag
val del : std_tag
val details : std_tag
val dfn : std_tag
val dialog : std_tag
val div : std_tag
val dl : std_tag
val dt : std_tag
val em : std_tag
val embed : void_tag
val fieldset : std_tag
val figcaption : std_tag
val figure : std_tag
val form : std_tag
val h1 : std_tag
val h2 : std_tag
val h3 : std_tag
val h4 : std_tag
val h5 : std_tag
val h6 : std_tag
val head : std_tag
val header : std_tag
val hgroup : std_tag
val hr : void_tag
val html : std_tag

A <!DOCTYPE html> declaration is automatically prefixed when this tag is printed.

val i : std_tag
val iframe : std_tag
val img : void_tag
val input : void_tag
val ins : std_tag
val kbd : std_tag
val label : std_tag
val legend : std_tag
val li : std_tag
val main : std_tag
val map : std_tag
val mark : std_tag
val menu : std_tag
val meta : void_tag
val meter : std_tag
val nav : std_tag
val noscript : std_tag
val object_ : std_tag
val ol : std_tag
val optgroup : std_tag
val option : _ text_tag
val output : std_tag
val p : std_tag
val picture : std_tag
val pre : std_tag
val progress : std_tag
val q : std_tag
val rp : std_tag
val rt : std_tag
val ruby : std_tag
val s : std_tag
val samp : std_tag
val script : _ text_tag

Note that the content of this tag is not escaped.

val section : std_tag
val select : std_tag
val slot : std_tag
val small : std_tag
val source : void_tag
val span : std_tag
val strong : std_tag
val style : _ text_tag

Note that the content of this tag is not escaped.

val sub : std_tag
val summary : std_tag
val sup : std_tag
val table : std_tag
val tbody : std_tag
val td : std_tag
val template : std_tag
val textarea : _ text_tag
val tfoot : std_tag
val th : std_tag
val thead : std_tag
val time : std_tag
val title : _ text_tag
val tr : std_tag
val track : void_tag
val u : std_tag
val ul : std_tag
val var : std_tag
val video : std_tag
val wbr : void_tag
diff --git a/pure-html/Pure_html/Hx/index.html b/pure-html/Pure_html/Hx/index.html new file mode 100644 index 0000000..c4638a0 --- /dev/null +++ b/pure-html/Pure_html/Hx/index.html @@ -0,0 +1,2 @@ + +Hx (pure-html.Pure_html.Hx)

Module Pure_html.Hx

htmx support https://htmx.org/reference/

val __ : _ string_attr

This attribute serves as the _ attribute, which is used by Hyperscript. Note that the value of this attribute is not escaped.

  • since 0.1.0.
val boost : bool to_attr
val confirm : _ string_attr
val delete : _ string_attr
val disable : attr
val disinherit : _ string_attr
val encoding_formdata : attr

Hardcoding of the hx-encoding attribute to multipart/form-data.

val ext : _ string_attr
val get : _ string_attr
val headers : _ string_attr
val history_false : attr

Hardcoding of the hx-history attribute to false.

val history_elt : attr
val include_ : _ string_attr
val indicator : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val on : _ string_attr

Note that the value of this attribute is not escaped.

  • deprecated See https://htmx.org/attributes/hx-on/#hx-on-deprecated
val on_ : event:string -> _ string_attr

The hx-on:* set of attributes, where * represents DOM events: https://htmx.org/attributes/hx-on/.

Note that the value of this attribute is not escaped.

  • since 2.1.0.
val params : _ string_attr
val patch : _ string_attr
val post : _ string_attr
val preload : attr
val preserve : attr
val prompt : _ string_attr
val push_url : _ string_attr
val put : _ string_attr
val replace_url : _ string_attr
val request : _ string_attr
val select : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val select_oob : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val sse_connect : _ string_attr
val sse_swap : _ string_attr
val swap : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val swap_oob : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val sync : _ string_attr
val target : _ string_attr

Note that the value of this attribute is not escaped as it may include a CSS selector.

val trigger : _ string_attr

Note that the value of this attribute is not escaped.

val validate : attr
val vals : _ string_attr
val ws_connect : _ string_attr
val ws_send : attr
diff --git a/pure-html/Pure_html/MathML/index.html b/pure-html/Pure_html/MathML/index.html new file mode 100644 index 0000000..7dafdb2 --- /dev/null +++ b/pure-html/Pure_html/MathML/index.html @@ -0,0 +1,2 @@ + +MathML (pure-html.Pure_html.MathML)

Module Pure_html.MathML

  • since 3.1.0.
val accent : bool to_attr
val accentunder : bool to_attr
val columnspan : int to_attr
val depth : _ string_attr
val dir : [ `ltr | `rtl ] to_attr
val display_block : attr

See https://developer.mozilla.org/en-US/docs/Web/MathML/Element/math#display. display=inline is the default, so there is no need to bind its value.

val displaystyle : bool to_attr
val fence : bool to_attr
val height : _ string_attr
val largeop : bool to_attr
val linethickness : _ string_attr
val lspace : _ string_attr
val mathvariant : _ string_attr
val maxsize : _ string_attr
val minsize : _ string_attr
val movablelimits : bool to_attr
val rowspan : int to_attr
val rspace : _ string_attr
val scriptlevel : _ string_attr
val separator : bool to_attr
val stretchy : bool to_attr
val symmetric : bool to_attr
val voffset : _ string_attr
val xmlns : attr
val annotation : std_tag
val annotation_xml : std_tag
val math : std_tag
val merror : std_tag
val mfrac : std_tag
val mi : std_tag
val mmultiscripts : std_tag
val mn : std_tag
val mo : std_tag
val mover : std_tag
val mpadded : std_tag
val mphantom : std_tag
val mroot : std_tag
val mrow : std_tag
val ms : std_tag
val mspace : std_tag
val msqrt : std_tag
val mstyle : std_tag
val msub : std_tag
val msubsup : std_tag
val msup : std_tag
val mtable : std_tag
val mtd : std_tag
val mtext : std_tag
val mtr : std_tag
val munder : std_tag
val munderover : std_tag
val semantics : std_tag
diff --git a/pure-html/Pure_html/SVG/index.html b/pure-html/Pure_html/SVG/index.html new file mode 100644 index 0000000..b632bf1 --- /dev/null +++ b/pure-html/Pure_html/SVG/index.html @@ -0,0 +1,3 @@ + +SVG (pure-html.Pure_html.SVG)

Module Pure_html.SVG

  • since 1.1.0.
val d : _ string_attr
val fill : _ string_attr
val stroke : _ string_attr
val stroke_linecap : [< `butt | `round | `square ] to_attr
val stroke_linejoin : + [< `arcs | `bevel | `miter | `miter_clip | `round ] to_attr
val stroke_width : _ string_attr
val viewbox : min_x:int -> min_y:int -> width:int -> height:int -> attr
val xmlns : attr
val path : std_tag
val svg : std_tag
diff --git a/pure-html/Pure_html/index.html b/pure-html/Pure_html/index.html new file mode 100644 index 0000000..b3be775 --- /dev/null +++ b/pure-html/Pure_html/index.html @@ -0,0 +1,11 @@ + +Pure_html (pure-html.Pure_html)

Module Pure_html

Use this module for constructing HTML without any dependency on the Dream web framework.

  • since 3.5.0.

Core types

These are the types of the final values which get rendered.

type attr

E.g. id="toast".

type node

Either a tag, a comment, or text data in the markup.

Output

val to_string : node -> string
val to_xml : node -> string

Same as to_string but render void tags as XML-style self-closing tags.

  • since 3.3.0.
val pp : Stdlib.Format.formatter -> node -> unit
val pp_xml : Stdlib.Format.formatter -> node -> unit

Same as pp but render void tags as XML-style self-closing tags.

  • since 3.3.0.

Constructing nodes and attributes

type 'a to_attr = 'a -> attr

Attributes can be created from typed values.

type 'a string_attr = ('a, unit, string, attr) Stdlib.format4 -> 'a

Special handling for string-value attributes so they can use format strings i.e. string interpolation.

type std_tag = attr list -> node list -> node

A 'standard' tag with attributes and children.

type void_tag = attr list -> node
type 'a text_tag = attr list -> ('a, unit, string, node) Stdlib.format4 -> 'a

Tags which can have attributes but can contain only text. The text can be formatted.

val attr : string -> attr

attr name is a new attribute which does not carry any payload. E.g.

let required = attr "required"
  • since 0.1.0.
val string_attr : string -> ?raw:bool -> _ string_attr

string_attr name fmt is a new string-valued attribute which allows formatting i.e. string interpolation of the value. Note, the fmt argument is required due to the value restriction.

val uri_attr : string -> _ string_attr

Convenience for attributes whose values should be URIs. Takes care of both URI-encoding and attribute escaping, as recommended in https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#common-mistake.

Examples

a [href "/blog?tags=iamsafe\"></a><script>alert('Pwned')</script>"] [txt "Tags: tag1 | tag2"]
+==>
+<a href="/blog?tags=iamsafe%22%3E%3C/a%3E%3Cscript%3Ealert('Pwned')%3C/script%3E">Tags: tag1 | tag2</a>
+
+a [href "/foo?a=1&b=2 3&c=4<5&d=6>5"] [txt "Test"]
+==>
+<a href="/foo?a=1&amp;b=2%203&amp;c=4%3C5&amp;d=6%3E5">Test</a>
val bool_attr : string -> bool to_attr
val float_attr : string -> float to_attr
val int_attr : string -> int to_attr
val std_tag : string -> std_tag
val void_tag : string -> void_tag
val text_tag : string -> ?raw:bool -> _ text_tag

Build a tag which can contain only text.

val txt : ?raw:bool -> ('a, unit, string, node) Stdlib.format4 -> 'a

A text node inside the DOM e.g. the 'hi' in <b>hi</b>. Allows string interpolation using the same formatting features as Printf.sprintf:

b [] [txt "Hello, %s!" name]

Or without interpolation:

b [] [txt "Bold of you."]

HTML-escapes the text value. You can use the ~raw param to bypass escaping:

let user_input = "<script>alert('I like HTML injection')</script>" in
+txt ~raw:true "%s" user_input
val comment : string -> node

A comment that will be embedded in the rendered HTML, i.e. <!-- comment -->. The text is HTML-escaped.

Accessors for tags

val (+@) : node -> attr -> node

Add an attribute to a tag.

let toast msg = p [id "toast"] [txt "%s" msg]
+let toast_oob = toast "ok." +@ Hx.swap_oob "true"
  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • since 0.0.3.
val (-@) : node -> string -> node

Remove an attribute from a tag.

  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • since 0.0.3.
val (.@[]) : node -> string -> string

Get the value of an existing attribute.

let toast = p [id "toast"] [txt "OK."]
+let toast_id = toast.@["id"]
  • raises Invalid_argument

    if the node is not a tag (i.e. if it is a text or comment node).

  • raises Not_found

    if the tag does not have the given attribute.

  • since 0.0.3.
val is_null : node -> bool

Get whether a node is null (empty) or not. Useful for conditional rendering of UIs when you are passed in a node and you don't know if it's empty or not.

  • since 1.2.0.
val is_null_ : attr -> bool

Get whether an attribute is null (empty) or not.

  • since 1.2.0.

Standard attributes and tags

module HTML : sig ... end

All standard HTML attributes and tags. Some attributes and tags have the same name, e.g. style. To disambiguate them, attributes have a _ (underscore) suffix.

module SVG : sig ... end
module MathML : sig ... end

ARIA support

htmx support

module Hx : sig ... end
diff --git a/pure-html/index.html b/pure-html/index.html new file mode 100644 index 0000000..a4dbecd --- /dev/null +++ b/pure-html/index.html @@ -0,0 +1,2 @@ + +index (pure-html.index)

pure-html index

Library pure-html

The entry point of this library is the module: Pure_html.