diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/html.c | 43 | ||||
-rw-r--r-- | src/html.h | 3 |
2 files changed, 46 insertions, 0 deletions
@@ -186,6 +186,49 @@ TEXT_ELEMENT(p) #undef TEXT_ELEMENT gchar * +mq_html_list(const gchar *type, ...) +{ + gsize len; + va_list ap; + gchar *child; + gchar *form; + gchar *ptr; + + /* TODO: Doesn't support specification of <ol> list types. */ + + /* Calculate length. */ + len = strlen("<ul>\n"); + va_start(ap, type); + while ((child = va_arg(ap, gchar *))) { + len += strlen("<li>\n"); + len += strlen(child); + len += strlen("</li>\n"); + } + va_end(ap); + len += strlen("</ul>\n"); + ++len; /* NUL byte */ + + /* Build string. */ + form = g_new(gchar, len); + if (type && type[0]) { + ptr = g_stpcpy(form, "<ol>\n"); + } else { + ptr = g_stpcpy(form, "<ul>\n"); + } + va_start(ap, type); + while ((child = va_arg(ap, gchar *))) { + ptr = g_stpcpy(ptr, "<li>\n"); + ptr = g_stpcpy(ptr, child); + g_free(child); + ptr = g_stpcpy(ptr, "</li>\n"); + } + va_end(ap); + ptr = g_stpcpy(ptr, "</ul>\n"); /* g_stpcpy() adds the NUL. */ + + return form; +} + +gchar * mq_html_container(const gchar *element, ...) { gsize len; @@ -45,6 +45,9 @@ gchar * mq_html_container(const gchar *element, ...); gchar * +mq_html_list(const gchar *type, ...); + +gchar * mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...); gchar * |