Print comments as comments, not as usual text nodes

master
Yevgen Muntyan 2006-12-10 16:52:33 -06:00
parent 49dd17f730
commit 35015e2b98
1 changed files with 25 additions and 2 deletions

View File

@ -95,6 +95,8 @@ static void moo_markup_element_print (MooMarkupElement *node,
GString *dest);
static void moo_markup_text_node_print (MooMarkupNode *node,
GString *dest);
static void moo_markup_comment_node_print (MooMarkupNode *node,
GString *dest);
static void start_element (GMarkupParseContext *context,
@ -550,9 +552,11 @@ moo_markup_node_get_string (MooMarkupNode *node)
moo_markup_element_print (MOO_MARKUP_ELEMENT (child), str);
break;
case MOO_MARKUP_TEXT_NODE:
case MOO_MARKUP_COMMENT_NODE:
moo_markup_text_node_print (child, str);
break;
case MOO_MARKUP_COMMENT_NODE:
moo_markup_comment_node_print (child, str);
break;
default:
g_assert_not_reached ();
}
@ -584,8 +588,10 @@ moo_markup_element_print (MooMarkupElement *node,
case MOO_MARKUP_ELEMENT_NODE:
moo_markup_element_print (MOO_MARKUP_ELEMENT (child), str);
break;
case MOO_MARKUP_TEXT_NODE:
case MOO_MARKUP_COMMENT_NODE:
moo_markup_comment_node_print (child, str);
break;
case MOO_MARKUP_TEXT_NODE:
moo_markup_text_node_print (child, str);
break;
default:
@ -617,6 +623,23 @@ moo_markup_text_node_print (MooMarkupNode *node,
}
static void
moo_markup_comment_node_print (MooMarkupNode *node,
GString *str)
{
char *p;
MooMarkupText *text = (MooMarkupText*) node;
if (!g_utf8_validate (text->text, -1, (const char**) &p))
{
g_critical ("%s: invalid UTF8", G_STRLOC);
*p = 0;
}
g_string_append (str, text->text);
}
const char*
moo_markup_get_content (MooMarkupNode *node)
{