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.
23
.Nd open an element scope for kcgihtml
34
.Fa "struct khtmlreq *req"
40
.Fa "struct khtmlreq *req"
45
Open a new scope of element
47
on the current element stack of
52
.Xr khtml_closeelem 3 ,
61
.Pq self-closing, like Dv KELEM_LINK
64
the scope is immediately closed so no new scope is opened.
68
variable arguments are in pairs, with the first of a pair being a
70
of the attribute type and the second being a
76
variable arguments are in triplets: the first is a
78
of the attribute type, the second is a
80
describing the data format of the third type, and the third type is
93
In both cases, string content is HTML escaped, for example, the
94
double-quote character is rendered as
96
This prevents arguments from
98
the attribute string context.
100
The variable arguments terminated with a singular
105
indicating the error state.
108
Success (not an error).
110
Internal memory allocation failure, including reaching the maximum
111
number of possible HTML scopes.
113
The output connection has been terminated.
114
For FastCGI connections, the current connection should be released with
116
and parse loop reentered.
118
The connection is still expecting headers with
122
did not return with success or was not invoked.
123
For FastCGI connections, the current connection should be released with
125
and parse loop reentered.
127
Internal system error writing to the output stream.
130
The following outputs a simple HTML page.
136
For brevity, it does not do any error checking.
137
.Bd -literal -offset indent
138
khttp_head(r, kresps[KRESP_STATUS],
139
"%s", khttps[KHTTP_200]);
140
khttp_head(r, kresps[KRESP_CONTENT_TYPE],
141
"%s", kmimetypes[KMIME_TEXT_HTML]);
143
khtml_open(&req, r, 0);
144
khtml_elem(&req, KELEM_DOCTYPE);
145
khtml_elem(&req, KELEM_HTML);
146
khtml_elem(&req, KELEM_HEAD);
147
khtml_attr(req, KELEM_META,
148
KATTR_CHARSET, "utf-8", KATTR__MAX);
149
khtml_attrx(req, KELEM_LINK,
150
KATTR_REL, KATTRX_STRING, "stylesheet",
151
KATTR_HREF, KATTRX_STRING, "style.css",
156
The latter invocation could just as easily use
161
The referenced HTML5 standard is
162
.Lk https://www.w3.org/TR/html52 HTML5.2 .
165
.An Kristaps Dzonsons Aq Mt kristaps@bsd.lv .