diff options
Diffstat (limited to '')
| -rw-r--r-- | xs_html.h | 57 | ||||
| -rw-r--r-- | xs_version.h | 2 |
2 files changed, 24 insertions, 35 deletions
| @@ -203,61 +203,50 @@ xs_html *_xs_html_container(xs_html *var[]) | |||
| 203 | void xs_html_render_f(xs_html *h, FILE *f) | 203 | void xs_html_render_f(xs_html *h, FILE *f) |
| 204 | /* renders the tag and its subtags into a file */ | 204 | /* renders the tag and its subtags into a file */ |
| 205 | { | 205 | { |
| 206 | xs_html *st; | 206 | if (h == NULL) |
| 207 | return; | ||
| 207 | 208 | ||
| 208 | switch (h->type) { | 209 | switch (h->type) { |
| 209 | case XS_HTML_TAG: | 210 | case XS_HTML_TAG: |
| 210 | case XS_HTML_SCTAG: | ||
| 211 | fprintf(f, "<%s", h->content); | 211 | fprintf(f, "<%s", h->content); |
| 212 | 212 | ||
| 213 | /* render the attributes */ | 213 | /* attributes */ |
| 214 | st = h->f_attr; | 214 | xs_html_render_f(h->f_attr, f); |
| 215 | while (st) { | ||
| 216 | xs_html *nst = st->next; | ||
| 217 | xs_html_render_f(st, f); | ||
| 218 | st = nst; | ||
| 219 | } | ||
| 220 | 215 | ||
| 221 | if (h->type == XS_HTML_SCTAG) { | 216 | fprintf(f, ">"); |
| 222 | /* self-closing tags should not have subtags */ | ||
| 223 | fprintf(f, "/>"); | ||
| 224 | } | ||
| 225 | else { | ||
| 226 | fprintf(f, ">"); | ||
| 227 | 217 | ||
| 228 | /* render the subtags */ | 218 | /* sub-tags */ |
| 229 | st = h->f_tag; | 219 | xs_html_render_f(h->f_tag, f); |
| 230 | while (st) { | ||
| 231 | xs_html *nst = st->next; | ||
| 232 | xs_html_render_f(st, f); | ||
| 233 | st = nst; | ||
| 234 | } | ||
| 235 | 220 | ||
| 236 | fprintf(f, "</%s>", h->content); | 221 | fprintf(f, "</%s>", h->content); |
| 237 | } | 222 | break; |
| 223 | |||
| 224 | case XS_HTML_SCTAG: | ||
| 225 | fprintf(f, "<%s", h->content); | ||
| 238 | 226 | ||
| 227 | /* attributes */ | ||
| 228 | xs_html_render_f(h->f_attr, f); | ||
| 229 | |||
| 230 | fprintf(f, "/>"); | ||
| 239 | break; | 231 | break; |
| 240 | 232 | ||
| 241 | case XS_HTML_CONTAINER: | 233 | case XS_HTML_CONTAINER: |
| 242 | /* render the subtags and nothing more */ | 234 | /* sub-tags */ |
| 243 | st = h->f_tag; | 235 | xs_html_render_f(h->f_tag, f); |
| 244 | while (st) { | ||
| 245 | xs_html *nst = st->next; | ||
| 246 | xs_html_render_f(st, f); | ||
| 247 | st = nst; | ||
| 248 | } | ||
| 249 | |||
| 250 | break; | 236 | break; |
| 251 | 237 | ||
| 252 | case XS_HTML_ATTR: | 238 | case XS_HTML_ATTR: |
| 253 | fprintf(f, " %s", h->content); | 239 | fprintf(f, " "); |
| 254 | break; | 240 | /* fallthrough */ |
| 255 | 241 | ||
| 256 | case XS_HTML_TEXT: | 242 | case XS_HTML_TEXT: |
| 257 | fprintf(f, "%s", h->content); | 243 | fprintf(f, "%s", h->content); |
| 258 | break; | 244 | break; |
| 259 | } | 245 | } |
| 260 | 246 | ||
| 247 | /* follow the chain */ | ||
| 248 | xs_html_render_f(h->next, f); | ||
| 249 | |||
| 261 | xs_free(h->content); | 250 | xs_free(h->content); |
| 262 | xs_free(h); | 251 | xs_free(h); |
| 263 | } | 252 | } |
diff --git a/xs_version.h b/xs_version.h index 89c899d..0e90e31 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* f27e092c79ca6e2e96f83e0d4c3dbc73d737ffaa 2023-12-03T17:12:47+01:00 */ | /* 1b21549513460489504a2caa4127607c914a10da 2023-12-03T23:45:32+01:00 */ | ||