3
.\" Copyright (c) 2020 Kristaps Dzonsons <kristaps@bsd.lv>
5
.\" Permission to use, copy, modify, and distribute this software for any
6
.\" purpose with or without fee is hereby granted, provided that the above
7
.\" copyright notice and this permission notice appear in all copies.
9
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
.Nd get element stack depth of kcgihtml
33
.Fa "const struct khtmlreq *req"
36
Gets the current depth of the element stack of
40
This is usually used with
43
If called before opening any element contexts (i.e., a depth
46
will close all open scopes.
48
The following outputs a simple HTML page.
54
For brevity, it does not do any error checking.
55
.Bd -literal -offset indent
56
khttp_head(r, kresps[KRESP_STATUS],
57
"%s", khttps[KHTTP_200]);
58
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
59
"%s", kmimetypes[KMIME_TEXT_HTML]);
61
khtml_open(&req, r, 0);
62
khtml_elem(&req, KELEM_DOCTYPE);
63
khtml_elem(&req, KELEM_HTML);
64
pos = khtml_elemat(&req); /* save at html */
65
khtml_elem(&req, KELEM_HEAD);
66
khtml_elem(&req, KELEM_TITLE);
67
khtml_puts(&req, "Hello, world.");
68
khtml_closeto(&req, pos); /* to html */
69
khtml_closeelem(&req, 1); /* head */
70
khtml_elem(&req, KELEM_BODY);
71
khtml_puts(&req, "Hello, world");
77
The referenced HTML5 standard is
78
.Lk https://www.w3.org/TR/html52 HTML5.2 .
81
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .
83
If called in a scope that's subsequently closed, then a new scope
84
reopened and filled in, a corresponding
86
will unwind the stack to the new scope.
87
In other words this does not identify a savepoint: it's merely the scope