2006-05-28 Matthias Clasen <mclasen@redhat.com>
+ * glib/gmarkup.h: Add a GMarkupParseFlags flag for
+ treating CDATA as text.
+
+ * glib/gmarkup.c (g_markup_parse_context_parse):
+ Implement it here.
+
+2006-05-28 Matthias Clasen <mclasen@redhat.com>
+
* tests/markups/expected-*: Output that test-markup
is expected to produce when run on the valid gmarkup
examples.
2006-05-28 Matthias Clasen <mclasen@redhat.com>
+ * glib/gmarkup.h: Add a GMarkupParseFlags flag for
+ treating CDATA as text.
+
+ * glib/gmarkup.c (g_markup_parse_context_parse):
+ Implement it here.
+
+2006-05-28 Matthias Clasen <mclasen@redhat.com>
+
* tests/markups/expected-*: Output that test-markup
is expected to produce when run on the valid gmarkup
examples.
+2006-05-28 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/tmpl/markup.sgml: Document G_MARKUP_TREAT_CDATA_AS_TEXT.
+
2006-05-16 Matthias Clasen <mclasen@redhat.com>
* glib/glib-sections.txt: Add g_ascii_strtoll
<!-- ##### ENUM GMarkupParseFlags ##### -->
<para>
-There are no flags right now. Pass "0" for the flags argument to all
-functions.
+Flags that affect the behaviour of the parser.
</para>
@G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use.
+@G_MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked
+ sections are not passed literally to the @passthrough function of
+ the parser. Instead, the content of the section (without the
+ <literal><![CDATA[</literal> and <literal>]]></literal>) is
+ passed to the @text function. This flag was added in GLib 2.12.
+
<!-- ##### STRUCT GMarkupParseContext ##### -->
<para>
</para>
@start_element: Callback to invoke when the opening tag of an element
-is seen.
-@end_element: Callback to invoke when the closing tag of an element is seen
+ is seen.
+@end_element: Callback to invoke when the closing tag of an element is seen.
+ Note that this is also called for empty tags like
+ <literal><empty/></literal>.
@text: Callback to invoke when some text is seen (text is always
-inside an element)
-@passthrough: Callback to invoke for comments, processing
-instructions and doctype declarations; if you're re-writing the parsed document, write the
-passthrough text back out in the same position
-@error: Callback to invoke when an error occurs
+ inside an element). Note that the text of an element may be spread
+ over multiple calls of this function. If the %G_MARKUP_TREAT_CDATA_AS_TEXT
+ flag is set, this function is also called for the content of CDATA marked
+ sections.
+@passthrough: Callback to invoke for comments, processing instructions
+ and doctype declarations; if you're re-writing the parsed document,
+ write the passthrough text back out in the same position. If the
+ %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also
+ called for CDATA marked sections.
+@error: Callback to invoke when an error occurs.
+
<!-- ##### FUNCTION g_markup_escape_text ##### -->
<para>
/* The passthrough hasn't necessarily ended. Merge with
* partial chunk, leave state unchanged.
*/
- add_to_partial (context, context->start, context->iter);
+ add_to_partial (context, context->start, context->iter);
}
else
{
advance_char (context); /* advance past close angle */
add_to_partial (context, context->start, context->iter);
- if (context->parser->passthrough)
+ if (context->flags & G_MARKUP_TREAT_CDATA_AS_TEXT &&
+ g_str_has_prefix (context->partial_chunk->str, "<![CDATA[") &&
+ g_str_has_suffix (context->partial_chunk->str, "]]>"))
+ {
+ if (context->parser->text)
+ (*context->parser->text) (context,
+ context->partial_chunk->str + strlen ("<![CDATA["),
+ context->partial_chunk->len - strlen ("<![CDATA[" "]]>"),
+ context->user_data,
+ &tmp_error);
+ }
+ else if (context->parser->passthrough)
(*context->parser->passthrough) (context,
context->partial_chunk->str,
context->partial_chunk->len,
typedef enum
{
- /* Hmm, can't think of any at the moment */
- G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0
-
+ G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
+ G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1
} GMarkupParseFlags;
typedef struct _GMarkupParseContext GMarkupParseContext;