| Top |
A callback receives borrowed immutable tag metadata and mutable decisions. It must explicitly write the desired tag; setting deletion flags does not undo previously written output. End-tag callbacks are opt-in. Writing a tag does not itself consult deletion or suppression flags.
gboolean (*GMimeHtmlTagCallback) (GMimeHtmlTagContext *context,GMimeHtmlWriter *writer,gpointer user_data,GError **error);
Writes the desired tag explicitly. The context is borrowed for the
duration of the callback and must not be freed or retained. Its attributes
are borrowed; use g_mime_html_attribute_ref() to retain an attribute
beyond the callback. The writer is borrowed and must not be freed by
the callback.
context |
borrowed tag metadata and mutable decisions. |
[transfer none] |
writer |
the borrowed output writer. |
[transfer none] |
user_data |
user data supplied when registering the callback. |
[nullable] |
error |
return location for a GError, or |
GMimeHtmlTagContext *
g_mime_html_tag_context_new (GMimeHtmlToken *token);
Creates a mutable context retaining a reference to token
. This allocation
API is C-only; language bindings receive borrowed contexts in callbacks.
Free the returned context with g_mime_html_tag_context_free().
[skip]
void
g_mime_html_tag_context_free (GMimeHtmlTagContext *context);
Frees an owned context and releases its token reference. This API is C-only. Do not free a borrowed context received in a GMimeHtmlTagCallback.
[skip]
context |
a context allocated by
|
[nullable][transfer full] |
void g_mime_html_tag_context_set_token (GMimeHtmlTagContext *context,GMimeHtmlToken *token);
Replaces the context's token, retaining a reference to token
and releasing
the previous token. Updates the end-tag state from token
without resetting
the deletion, suppression or callback flags.
const char *
g_mime_html_tag_context_get_tag_name (GMimeHtmlTagContext *context);
Gets the current token's tag name.
GMimeHtmlTagId
g_mime_html_tag_context_get_tag_id (GMimeHtmlTagContext *context);
Gets the known tag identifier for the current token.
guint
g_mime_html_tag_context_get_n_attributes
(GMimeHtmlTagContext *context);
Gets the number of attributes on the current token.
const GMimeHtmlAttribute * g_mime_html_tag_context_get_attribute (GMimeHtmlTagContext *context,guint index);
Gets an attribute by its zero-based index. The attribute is owned by the
token; retain it with g_mime_html_attribute_ref() if it must outlive the
current token or callback.
gboolean
g_mime_html_tag_context_get_is_empty_element_tag
(GMimeHtmlTagContext *context);
Gets whether the token is self-closing or its tag is a known HTML void element.
gboolean
g_mime_html_tag_context_get_is_end_tag
(GMimeHtmlTagContext *context);
Gets whether the context currently represents an end tag.
void g_mime_html_tag_context_set_is_end_tag (GMimeHtmlTagContext *context,gboolean value);
Changes how g_mime_html_tag_context_write_tag() writes the tag without
modifying the underlying token.
gboolean
g_mime_html_tag_context_get_delete_tag
(GMimeHtmlTagContext *context);
Gets whether the callback has marked the current tag as deleted.
void g_mime_html_tag_context_set_delete_tag (GMimeHtmlTagContext *context,gboolean value);
Records the callback's decision to omit the tag. The callback must also
refrain from writing it: this flag neither undoes output nor prevents an
explicit call to g_mime_html_tag_context_write_tag(). Inner-content and
matching-end-tag suppression are controlled separately.
gboolean
g_mime_html_tag_context_get_delete_end_tag
(GMimeHtmlTagContext *context);
Gets whether automatic output of the matching end tag is suppressed.
void g_mime_html_tag_context_set_delete_end_tag (GMimeHtmlTagContext *context,gboolean value);
Records whether the converter should omit the matching end tag. This flag does not prevent explicit writes by a tag callback.
gboolean
g_mime_html_tag_context_get_suppress_inner_content
(GMimeHtmlTagContext *context);
Gets whether output of the element's inner content is suppressed.
void g_mime_html_tag_context_set_suppress_inner_content (GMimeHtmlTagContext *context,gboolean value);
Requests suppression of text and nested elements inside the current element. Set this in the start-tag callback. The element's own start and end tags are controlled separately.
gboolean
g_mime_html_tag_context_get_invoke_callback_for_end_tag
(GMimeHtmlTagContext *context);
Gets whether a callback is requested for the matching end tag.
void g_mime_html_tag_context_set_invoke_callback_for_end_tag (GMimeHtmlTagContext *context,gboolean value);
Requests a callback for the matching end tag instead of the default automatic write. Set this in the start-tag callback. The end-tag callback is responsible for writing any desired closing tag.
gboolean g_mime_html_tag_context_write_tag (GMimeHtmlTagContext *context,GMimeHtmlWriter *writer,gboolean write_attributes,GError **error);
Writes the current tag using the context's end-tag state and token metadata. Attributes are written only for start or empty-element tags. This function does not consult the deletion or suppression flags, and does not flush or close the writer.