| Top |
Rewrites HTML with optional comment filtering, fragment output, noscript handling and tag callbacks. Compliance diagnostics describe lexical and structural recovery without changing the output.
This converter is not a sanitizer. In particular, raw HTML headers and footers bypass filtering and callbacks.
GMimeTextConverter *
g_mime_html_to_html_new (void);
Creates an HTML rewriting converter. By default, comments and document structure are retained, noscript elements are unwrapped, and headers and footers are interpreted as plain text. This converter is not a sanitizer.
gboolean
g_mime_html_to_html_get_filter_comments
(GMimeHtmlToHtml *converter);
Gets whether HTML comments are omitted from the output.
void g_mime_html_to_html_set_filter_comments (GMimeHtmlToHtml *converter,gboolean value);
Enables or disables comment filtering. Removing comments does not make the output safe for use as untrusted HTML.
gboolean
g_mime_html_to_html_get_output_html_fragment
(GMimeHtmlToHtml *converter);
Gets whether document structure is removed to produce a fragment.
void g_mime_html_to_html_set_output_html_fragment (GMimeHtmlToHtml *converter,gboolean value);
When enabled, omits the doctype, html and body tags, and the head element with its contents. Configured headers and footers are still included. When disabled, document structure from the input is retained rather than synthesizing wrappers around an input fragment.
guint
g_mime_html_to_html_get_max_element_depth
(GMimeHtmlToHtml *converter);
Gets the tokenizer's maximum number of distinct open-element stack entries.
void g_mime_html_to_html_set_max_element_depth (GMimeHtmlToHtml *converter,guint value);
Limits the tokenizer's distinct open-element stack entries. By default,
the tag that exceeds the limit is processed and the remaining input is
treated as literal text. See g_mime_html_to_html_set_limit_exceeded_behavior().
A depth-limit diagnostic is reported when a compliance logger is registered.
gboolean
g_mime_html_to_html_get_formatting_recovery_enabled
(GMimeHtmlToHtml *converter);
void g_mime_html_to_html_set_formatting_recovery_enabled (GMimeHtmlToHtml *converter,gboolean enabled);
Follow reconstructed formatting when interpreting malformed HTML. This does
not synthesize tag callbacks or guarantee browser-equivalent parsing. If
recovery cannot continue, the remaining visible input is written as literal
text unless g_mime_html_to_html_set_limit_exceeded_behavior() selects failure.
With recovery disabled, malformed formatting mixed with SVG or MathML can
make a source tag part of text or a comment, so the callback will not see it.
GMimeHtmlLimitExceededBehavior
g_mime_html_to_html_get_limit_exceeded_behavior
(GMimeHtmlToHtml *converter);
void g_mime_html_to_html_set_limit_exceeded_behavior (GMimeHtmlToHtml *converter,GMimeHtmlLimitExceededBehavior value);
By default the remaining input is processed as text, not markup. In fail
mode conversion stops with GMIME_ERROR_PARSE_ERROR in the GMIME_ERROR
domain before the triggering token is processed by the converter. Output
already written to the destination is not rolled back.
GMimeHeaderFooterFormat
g_mime_html_to_html_get_header_format (GMimeHtmlToHtml *converter);
Gets how the configured header is interpreted.
void g_mime_html_to_html_set_header_format (GMimeHtmlToHtml *converter,GMimeHeaderFooterFormat value);
Selects how the header set by g_mime_text_converter_set_header() is written.
Text is independently converted to HTML. HTML is copied verbatim without
filtering, sanitization or tag callbacks.
GMimeHeaderFooterFormat
g_mime_html_to_html_get_footer_format (GMimeHtmlToHtml *converter);
Gets how the configured footer is interpreted.
void g_mime_html_to_html_set_footer_format (GMimeHtmlToHtml *converter,GMimeHeaderFooterFormat value);
Selects how the footer set by g_mime_text_converter_set_footer() is written.
Text is independently converted to HTML. HTML is copied verbatim without
filtering, sanitization or tag callbacks.
GMimeHtmlNoScriptHandling
g_mime_html_to_html_get_no_script_handling
(GMimeHtmlToHtml *converter);
Gets how noscript elements and their contents are parsed and written.
void g_mime_html_to_html_set_no_script_handling (GMimeHtmlToHtml *converter,GMimeHtmlNoScriptHandling value);
Selects noscript parsing and output. The default unwrap mode parses its contents as HTML and removes the noscript tags independently of the renderer's scripting setting. The other modes require the renderer's scripting setting to match the selected mode. None of these modes makes the converter a sanitizer.
void g_mime_html_to_html_set_html_tag_callback (GMimeHtmlToHtml *converter,GMimeHtmlTagCallback callback,gpointer user_data,GDestroyNotify destroy);
Sets the HTML tag callback, or restores default tag output if callback
is NULL. The callback must explicitly write any desired tag; end-tag
callbacks are opt-in through GMimeHtmlTagContext. Headers and footers
do not invoke the callback.
The previous destroy notifier is called when replacing the registration.
destroy
is called when this registration is replaced or the converter
is finalized. The callback cannot be changed during conversion.
GMimeHtmlTagCallback g_mime_html_to_html_get_html_tag_callback (GMimeHtmlToHtml *converter,gpointer *user_data);
Gets the currently registered HTML tag callback.
[skip]
converter |
||
user_data |
the callback's borrowed user data. |
[out][optional][nullable][transfer none] |
void g_mime_html_to_html_set_compliance_logger (GMimeHtmlToHtml *converter,GMimeHtmlComplianceLogger logger,gpointer user_data,GDestroyNotify destroy);
Sets the compliance logger, or clears it if logger
is NULL. Diagnostics
are borrowed for the duration of the callback and do not change output.
The previous destroy notifier is called when replacing the registration.
destroy
is called when this registration is replaced or the converter
is finalized. The logger cannot be changed during conversion.
GMimeHtmlComplianceLogger g_mime_html_to_html_get_compliance_logger (GMimeHtmlToHtml *converter,gpointer *user_data);
Gets the currently registered HTML compliance logger.
[skip]
converter |
||
user_data |
the logger's borrowed user data. |
[out][optional][nullable][transfer none] |
GMimeHtmlComplianceOptions *
g_mime_html_to_html_get_compliance_options
(GMimeHtmlToHtml *converter);
Gets the converter's HTML compliance options.
void g_mime_html_to_html_set_compliance_options (GMimeHtmlToHtml *converter,GMimeHtmlComplianceOptions *options);
Sets the compliance options. The converter retains a reference to options
.
typedef struct _GMimeHtmlToHtml GMimeHtmlToHtml;
Rewrites HTML with optional tag callbacks and compliance reporting. This converter is not an HTML sanitizer.
Controls noscript parsing and output in GMimeHtmlToHtml. Normal filtering and tag callbacks still apply. These modes do not make the converter a sanitizer.
|
Parse with scripting disabled and omit the noscript start and end tags while processing their contents as HTML. This is the default, renderer-independent mode. |
||
|
Parse with scripting enabled, treating noscript contents as raw text and retaining the noscript tags. The output renderer must also have scripting enabled. |
||
|
Parse with scripting disabled, processing noscript contents as HTML and retaining the noscript tags. The output renderer must also have scripting disabled. |