GMimeHtmlToText

GMimeHtmlToText — Plain-text rendering of HTML

Functions

Types and Values

Description

Renders HTML as plain text with optional link destinations and image alternative text. Lists, quotations and preformatted text retain their plain-text structure, and generated line endings are LF.

Length limits count Unicode scalar values rather than bytes or UTF-16 code units. Headers and footers are copied as plain text and are not included in the input or output length limits.

Functions

g_mime_html_to_text_new ()

GMimeTextConverter *
g_mime_html_to_text_new (void);

Creates an HTML to plain-text converter. Link URLs and image alternative text are included by default. Generated line endings are LF; configured headers and footers are copied as plain text.

Returns

a new GMimeHtmlToText.

[transfer full]


g_mime_html_to_text_get_output_link_urls ()

gboolean
g_mime_html_to_text_get_output_link_urls
                               (GMimeHtmlToText *converter);

Gets whether link destinations are included in the output.

Parameters

converter

a GMimeHtmlToText

 

Returns

TRUE if link URLs are included (the default).


g_mime_html_to_text_set_output_link_urls ()

void
g_mime_html_to_text_set_output_link_urls
                               (GMimeHtmlToText *converter,
                                gboolean value);

Controls whether a link's URL is appended in parentheses when its visible text differs from the URL. Empty links output the URL alone. Disabling this option preserves visible link text but omits the destination.

Parameters

converter

a GMimeHtmlToText

 

value

whether to include link destinations

 

g_mime_html_to_text_get_output_image_alt_text ()

gboolean
g_mime_html_to_text_get_output_image_alt_text
                               (GMimeHtmlToText *converter);

Gets whether image alternative text is included in the output.

Parameters

converter

a GMimeHtmlToText

 

Returns

TRUE if image alt attributes are rendered (the default).


g_mime_html_to_text_set_output_image_alt_text ()

void
g_mime_html_to_text_set_output_image_alt_text
                               (GMimeHtmlToText *converter,
                                gboolean value);

Controls whether an image's alternative text is rendered as plain text. Images without an alt attribute contribute no text.

Parameters

converter

a GMimeHtmlToText

 

value

whether to render image alt attributes

 

g_mime_html_to_text_get_max_element_depth ()

guint
g_mime_html_to_text_get_max_element_depth
                               (GMimeHtmlToText *converter);

Gets the tokenizer's maximum number of distinct open-element stack entries.

Parameters

converter

a GMimeHtmlToText

 

Returns

the element depth limit, initially 4096.


g_mime_html_to_text_set_max_element_depth ()

void
g_mime_html_to_text_set_max_element_depth
                               (GMimeHtmlToText *converter,
                                guint value);

Limits the tokenizer's distinct open-element stack entries. After this limit is exceeded, the remaining input is treated as literal text rather than parsed as markup.

Parameters

converter

a GMimeHtmlToText

 

value

the maximum element depth, from 1 to G_MAXINT

 

g_mime_html_to_text_get_max_input_length ()

gsize
g_mime_html_to_text_get_max_input_length
                               (GMimeHtmlToText *converter);

Gets the input length limit in Unicode scalar values, including HTML markup but excluding the configured header and footer.

Parameters

converter

a GMimeHtmlToText

 

Returns

the input length limit, initially 16 * 1024 * 1024.


g_mime_html_to_text_set_max_input_length ()

void
g_mime_html_to_text_set_max_input_length
                               (GMimeHtmlToText *converter,
                                gsize value);

Limits decoded HTML input, including markup. The limit counts Unicode scalar values, not bytes or UTF-16 code units. Exceeding it causes conversion to fail with an error.

Parameters

converter

a GMimeHtmlToText

 

value

the maximum input length in Unicode scalar values, greater than zero

 

g_mime_html_to_text_get_max_output_length ()

gsize
g_mime_html_to_text_get_max_output_length
                               (GMimeHtmlToText *converter);

Gets the rendered text length limit in Unicode scalar values. Configured headers and footers do not count toward this limit.

Parameters

converter

a GMimeHtmlToText

 

Returns

the output length limit, initially 64 * 1024 * 1024.


g_mime_html_to_text_set_max_output_length ()

void
g_mime_html_to_text_set_max_output_length
                               (GMimeHtmlToText *converter,
                                gsize value);

Limits the rendered body text before output charset encoding. Headers and footers are excluded. Exceeding the limit causes conversion to fail with an error.

Parameters

converter

a GMimeHtmlToText

 

value

the maximum output length in Unicode scalar values, greater than zero

 

Types and Values

GMimeHtmlToText

typedef struct _GMimeHtmlToText GMimeHtmlToText;

Renders HTML as plain text with configurable links, images and resource limits.