diff options
-rw-r--r-- | src/utils/html.c | 34 | ||||
-rw-r--r-- | src/utils/html.h | 7 |
2 files changed, 30 insertions, 11 deletions
diff --git a/src/utils/html.c b/src/utils/html.c index 5ee7313..936ba05 100644 --- a/src/utils/html.c +++ b/src/utils/html.c @@ -194,7 +194,8 @@ static const gchar *global_styles = ; gchar * -mq_html_document(const gchar *title, const gchar *styles, ...) +mq_html_document(const gchar *title, const gchar *styles, + const gchar *head_tags, ...) { gsize len; va_list ap; @@ -210,8 +211,12 @@ mq_html_document(const gchar *title, const gchar *styles, ...) len += strlen("</title>\n<style>\n"); len += strlen(global_styles); len += strlen(styles); - len += strlen("</style>\n</head>\n<body>\n"); - va_start(ap, styles); + len += strlen("</style>\n"); + if (head_tags) { + len += strlen(head_tags); + } + len += strlen("</head>\n<body>\n"); + va_start(ap, head_tags); while ((child = va_arg(ap, gchar *))) { len += strlen(child); } @@ -229,8 +234,12 @@ mq_html_document(const gchar *title, const gchar *styles, ...) ptr = g_stpcpy(ptr, "</title>\n<style>\n"); ptr = g_stpcpy(ptr, global_styles); ptr = g_stpcpy(ptr, styles); - ptr = g_stpcpy(ptr, "</style>\n</head>\n<body>\n"); - va_start(ap, styles); + ptr = g_stpcpy(ptr, "</style>\n"); + if (head_tags) { + ptr = g_stpcpy(ptr, head_tags); + } + ptr = g_stpcpy(ptr, "</head>\n<body>\n"); + va_start(ap, head_tags); while ((child = va_arg(ap, gchar *))) { ptr = g_stpcpy(ptr, child); g_free(child); @@ -242,7 +251,8 @@ mq_html_document(const gchar *title, const gchar *styles, ...) } gchar * -mq_html_document_v(const gchar *title, const gchar *styles, gchar **children) +mq_html_document_v(const gchar *title, const gchar *styles, + const gchar *head_tags, gchar **children) { gsize len; gsize i; @@ -257,7 +267,11 @@ mq_html_document_v(const gchar *title, const gchar *styles, gchar **children) len += strlen("</title>\n<style>\n"); len += strlen(global_styles); len += strlen(styles); - len += strlen("</style>\n</head>\n<body>\n"); + len += strlen("</style>\n"); + if (head_tags) { + len += strlen(head_tags); + } + len += strlen("</head>\n<body>\n"); for (i = 0; children && children[i]; ++i) { len += strlen(children[i]); } @@ -274,7 +288,11 @@ mq_html_document_v(const gchar *title, const gchar *styles, gchar **children) ptr = g_stpcpy(ptr, "</title>\n<style>\n"); ptr = g_stpcpy(ptr, global_styles); ptr = g_stpcpy(ptr, styles); - ptr = g_stpcpy(ptr, "</style>\n</head>\n<body>\n"); + ptr = g_stpcpy(ptr, "</style>\n"); + if (head_tags) { + ptr = g_stpcpy(ptr, head_tags); + } + ptr = g_stpcpy(ptr, "</head>\n<body>\n"); for (i = 0; children && children[i]; ++i) { ptr = g_stpcpy(ptr, children[i]); } diff --git a/src/utils/html.h b/src/utils/html.h index ffdddc2..2d33994 100644 --- a/src/utils/html.h +++ b/src/utils/html.h @@ -27,11 +27,12 @@ G_BEGIN_DECLS gchar * -mq_html_document(const gchar *title, const gchar *styles, ...) - G_GNUC_NULL_TERMINATED; +mq_html_document(const gchar *title, const gchar *styles, + const gchar *head_tags, ...) G_GNUC_NULL_TERMINATED; gchar * -mq_html_document_v(const gchar *title, const gchar *styles, gchar **children); +mq_html_document_v(const gchar *title, const gchar *styles, + const gchar *head_tags, gchar **children); #define TEXT_ELEMENT(ELEM) \ gchar * \ |