guint level;
gchar *str;
gchar *tags;
+ GString *body;
} Header;
static void
{
g_printf ("\tTAGS %s\n", h->tags);
}
+ if (h->body != NULL)
+ {
+ g_printf ("\tBODY %s", h->body->str);
+ }
return FALSE;
}
g_regex_match (regex, strline, 0, &match_info);
- Header *h = g_new0 (Header, 1);
- for (l = 0; l < i - start; l++)
+ if (strline[0] != '*')
{
- if (strline[l] == ' ')
+ Header *h = (Header *)cur->data;
+ if (h->body == NULL)
{
- h->level = l;
- break;
+ h->body = g_string_new ("");
}
- }
-
- rx_start = 0;
- h->tags = g_match_info_fetch (match_info, 0);
- if (h->tags != NULL)
- {
- g_match_info_fetch_pos (match_info, 0, &rx_start, NULL);
- }
-
- if (rx_start > 0)
- {
- h->str = g_strndup (strline + h->level + 1, rx_start - (h->level + 1));
+ g_string_append_printf (h->body, "%s\n", strline);
}
else
{
- h->str = g_strdup (strline + h->level + 1);
- }
- g_strstrip (h->str);
+ Header *h = g_new0 (Header, 1);
+ h->body = NULL;
+ for (l = 0; l < i - start; l++)
+ {
+ if (strline[l] == ' ')
+ {
+ h->level = l;
+ break;
+ }
+ }
- g_match_info_free (match_info);
- g_free (strline);
+ rx_start = 0;
+ h->tags = g_match_info_fetch (match_info, 0);
+ if (h->tags != NULL)
+ {
+ g_match_info_fetch_pos (match_info, 0, &rx_start, NULL);
+ }
- GNode *n = g_node_new (h);
+ if (rx_start > 0)
+ {
+ h->str = g_strndup (strline + h->level + 1, rx_start - (h->level + 1));
+ }
+ else
+ {
+ h->str = g_strdup (strline + h->level + 1);
+ }
+ g_strstrip (h->str);
- if (h->level == 0)
- {
- cur = root;
- }
- else
- {
- Header *hcur = (Header *)cur->data;
- if (h->level == hcur->level)
+ g_match_info_free (match_info);
+ g_free (strline);
+
+ GNode *n = g_node_new (h);
+
+ if (h->level == 0)
+ {
+ cur = root;
+ }
+ else
{
- cur = cur->parent;
+ Header *hcur = (Header *)cur->data;
+ if (h->level == hcur->level)
+ {
+ cur = cur->parent;
+ }
}
+ g_node_append (cur, n);
+ cur = n;
}
- g_node_append (cur, n);
- cur = n;
}
}