From ed885e115eb844d3be8bc88081a1af092a13bb06 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 01 Oct 2017 06:02:27 -0400 Subject: mq_html_h*(): New functions Declare and define them all with macros. --- (limited to 'src/html.c') diff --git a/src/html.c b/src/html.c index afcae07..8b93448 100644 --- a/src/html.c +++ b/src/html.c @@ -162,23 +162,28 @@ mq_html_document(const gchar *title, ...) return document; } -gchar * -mq_html_p(gchar *text) -{ - return g_strconcat("

", text, "

", NULL); -} - -gchar * -mq_html_p_free(gchar *text) -{ - gchar *p; - - p = g_strconcat("

", text, "

", NULL); - - g_free(text); - - return p; -} +#define TEXT_ELEMENT(ELEM) \ + gchar * \ + mq_html_##ELEM(gchar *text) \ + { \ + return g_strconcat("<" #ELEM ">", text, "", NULL); \ + } \ + gchar * \ + mq_html_##ELEM##_free(gchar *text) \ + { \ + gchar *p; \ + p = g_strconcat("<" #ELEM ">", text, "", NULL); \ + g_free(text); \ + return p; \ + } +TEXT_ELEMENT(h1) +TEXT_ELEMENT(h2) +TEXT_ELEMENT(h3) +TEXT_ELEMENT(h4) +TEXT_ELEMENT(h5) +TEXT_ELEMENT(h6) +TEXT_ELEMENT(p) +#undef TEXT_ELEMENT gchar * mq_html_container(const gchar *element, ...) -- cgit v0.9.1