GMimeHtmlTagContext

GMimeHtmlTagContext — Borrowed tag metadata and conversion decisions

Functions

Types and Values

Description

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.

Functions

GMimeHtmlTagCallback ()

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.

Parameters

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 NULL

 

Returns

TRUE on success, or FALSE to abort conversion with error set.


g_mime_html_tag_context_new ()

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]

Parameters

token

a tag token.

[transfer none]

Returns

a newly allocated GMimeHtmlTagContext.

[transfer full]


g_mime_html_tag_context_free ()

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]

Parameters

context

a context allocated by g_mime_html_tag_context_new(), or NULL.

[nullable][transfer full]

g_mime_html_tag_context_set_token ()

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.

Parameters

context

an HTML tag context

 

token

a tag token.

[transfer none]

g_mime_html_tag_context_get_tag_name ()

const char *
g_mime_html_tag_context_get_tag_name (GMimeHtmlTagContext *context);

Gets the current token's tag name.

Parameters

context

an HTML tag context

 

Returns

the tag name, valid until the token is replaced or the context is freed.

[transfer none]


g_mime_html_tag_context_get_tag_id ()

GMimeHtmlTagId
g_mime_html_tag_context_get_tag_id (GMimeHtmlTagContext *context);

Gets the known tag identifier for the current token.

Parameters

context

an HTML tag context

 

Returns

the tag identifier, or GMIME_HTML_TAG_UNKNOWN for an unknown name.


g_mime_html_tag_context_get_n_attributes ()

guint
g_mime_html_tag_context_get_n_attributes
                               (GMimeHtmlTagContext *context);

Gets the number of attributes on the current token.

Parameters

context

an HTML tag context

 

Returns

the attribute count.


g_mime_html_tag_context_get_attribute ()

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.

Parameters

context

an HTML tag context

 

index

an attribute index, less than the attribute count

 

Returns

the requested attribute.

[transfer none]


g_mime_html_tag_context_get_is_empty_element_tag ()

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.

Parameters

context

an HTML tag context

 

Returns

TRUE if the tag represents an empty element.


g_mime_html_tag_context_get_is_end_tag ()

gboolean
g_mime_html_tag_context_get_is_end_tag
                               (GMimeHtmlTagContext *context);

Gets whether the context currently represents an end tag.

Parameters

context

an HTML tag context

 

Returns

TRUE for an end tag, or FALSE for a start tag.


g_mime_html_tag_context_set_is_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.

Parameters

context

an HTML tag context

 

value

whether the context represents an end tag

 

g_mime_html_tag_context_get_delete_tag ()

gboolean
g_mime_html_tag_context_get_delete_tag
                               (GMimeHtmlTagContext *context);

Gets whether the callback has marked the current tag as deleted.

Parameters

context

an HTML tag context

 

Returns

the deletion flag, initially FALSE.


g_mime_html_tag_context_set_delete_tag ()

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.

Parameters

context

an HTML tag context

 

value

whether the current tag is marked as deleted

 

g_mime_html_tag_context_get_delete_end_tag ()

gboolean
g_mime_html_tag_context_get_delete_end_tag
                               (GMimeHtmlTagContext *context);

Gets whether automatic output of the matching end tag is suppressed.

Parameters

context

an HTML tag context

 

Returns

the end-tag deletion flag, initially FALSE.


g_mime_html_tag_context_set_delete_end_tag ()

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.

Parameters

context

an HTML tag context

 

value

whether to suppress automatic output of the matching end tag

 

g_mime_html_tag_context_get_suppress_inner_content ()

gboolean
g_mime_html_tag_context_get_suppress_inner_content
                               (GMimeHtmlTagContext *context);

Gets whether output of the element's inner content is suppressed.

Parameters

context

an HTML tag context

 

Returns

the inner-content suppression flag, initially FALSE.


g_mime_html_tag_context_set_suppress_inner_content ()

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.

Parameters

context

an HTML tag context

 

value

whether to suppress the element's inner content

 

g_mime_html_tag_context_get_invoke_callback_for_end_tag ()

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.

Parameters

context

an HTML tag context

 

Returns

the end-tag callback flag, initially FALSE.


g_mime_html_tag_context_set_invoke_callback_for_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.

Parameters

context

an HTML tag context

 

value

whether to request an end-tag callback

 

g_mime_html_tag_context_write_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.

Parameters

context

an HTML tag context

 

writer

the HTML writer

 

write_attributes

whether to write the current token's attributes

 

error

return location for a GError, or NULL

 

Returns

TRUE on success, or FALSE with error set on failure.

Types and Values

GMimeHtmlTagContext

typedef struct _GMimeHtmlTagContext GMimeHtmlTagContext;

enum GMimeHeaderFooterFormat

Specifies how HTML-producing converters interpret their configured headers and footers. Raw HTML is not sanitized.

Members

GMIME_HEADER_FOOTER_FORMAT_TEXT

Convert the header or footer from plain text.

 

GMIME_HEADER_FOOTER_FORMAT_HTML

Copy the header or footer as raw HTML.