- else
- g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
- _("text may not appear inside <%s>"),
- g_markup_parse_context_get_element (context));
+ if (state->string)
+ {
+ /* we are expecting a string, so store the text data.
+ *
+ * we store the data verbatim here and deal with whitespace
+ * later on. there are two reasons for that:
+ *
+ * 1) whitespace is handled differently depending on the tag
+ * type.
+ *
+ * 2) we could do leading whitespace removal by refusing to
+ * insert it into state->string if it's at the start, but for
+ * trailing whitespace, we have no idea if there is another
+ * text() call coming or not.
+ */
+ g_string_append_len (state->string, text, text_len);
+ }
+ else
+ {
+ /* string is not expected: accept (and ignore) pure whitespace */
+ gsize i;