mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Backport from xs.
This commit is contained in:
parent
5f047d46c0
commit
b17aa7d522
2 changed files with 26 additions and 37 deletions
59
xs_html.h
59
xs_html.h
|
@ -203,61 +203,50 @@ xs_html *_xs_html_container(xs_html *var[])
|
||||||
void xs_html_render_f(xs_html *h, FILE *f)
|
void xs_html_render_f(xs_html *h, FILE *f)
|
||||||
/* renders the tag and its subtags into a file */
|
/* renders the tag and its subtags into a file */
|
||||||
{
|
{
|
||||||
xs_html *st;
|
if (h == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
switch (h->type) {
|
switch (h->type) {
|
||||||
case XS_HTML_TAG:
|
case XS_HTML_TAG:
|
||||||
|
fprintf(f, "<%s", h->content);
|
||||||
|
|
||||||
|
/* attributes */
|
||||||
|
xs_html_render_f(h->f_attr, f);
|
||||||
|
|
||||||
|
fprintf(f, ">");
|
||||||
|
|
||||||
|
/* sub-tags */
|
||||||
|
xs_html_render_f(h->f_tag, f);
|
||||||
|
|
||||||
|
fprintf(f, "</%s>", h->content);
|
||||||
|
break;
|
||||||
|
|
||||||
case XS_HTML_SCTAG:
|
case XS_HTML_SCTAG:
|
||||||
fprintf(f, "<%s", h->content);
|
fprintf(f, "<%s", h->content);
|
||||||
|
|
||||||
/* render the attributes */
|
/* attributes */
|
||||||
st = h->f_attr;
|
xs_html_render_f(h->f_attr, f);
|
||||||
while (st) {
|
|
||||||
xs_html *nst = st->next;
|
|
||||||
xs_html_render_f(st, f);
|
|
||||||
st = nst;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (h->type == XS_HTML_SCTAG) {
|
|
||||||
/* self-closing tags should not have subtags */
|
|
||||||
fprintf(f, "/>");
|
fprintf(f, "/>");
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(f, ">");
|
|
||||||
|
|
||||||
/* render the subtags */
|
|
||||||
st = h->f_tag;
|
|
||||||
while (st) {
|
|
||||||
xs_html *nst = st->next;
|
|
||||||
xs_html_render_f(st, f);
|
|
||||||
st = nst;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(f, "</%s>", h->content);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XS_HTML_CONTAINER:
|
case XS_HTML_CONTAINER:
|
||||||
/* render the subtags and nothing more */
|
/* sub-tags */
|
||||||
st = h->f_tag;
|
xs_html_render_f(h->f_tag, f);
|
||||||
while (st) {
|
|
||||||
xs_html *nst = st->next;
|
|
||||||
xs_html_render_f(st, f);
|
|
||||||
st = nst;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XS_HTML_ATTR:
|
case XS_HTML_ATTR:
|
||||||
fprintf(f, " %s", h->content);
|
fprintf(f, " ");
|
||||||
break;
|
/* fallthrough */
|
||||||
|
|
||||||
case XS_HTML_TEXT:
|
case XS_HTML_TEXT:
|
||||||
fprintf(f, "%s", h->content);
|
fprintf(f, "%s", h->content);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* follow the chain */
|
||||||
|
xs_html_render_f(h->next, f);
|
||||||
|
|
||||||
xs_free(h->content);
|
xs_free(h->content);
|
||||||
xs_free(h);
|
xs_free(h);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
/* f27e092c79ca6e2e96f83e0d4c3dbc73d737ffaa 2023-12-03T17:12:47+01:00 */
|
/* 1b21549513460489504a2caa4127607c914a10da 2023-12-03T23:45:32+01:00 */
|
||||||
|
|
Loading…
Reference in a new issue