Struct html5ever_ext::UltraMinifyingHtmlSerializer [] [src]

pub struct UltraMinifyingHtmlSerializer<W: Write> { /* fields omitted */ }

A serializer that, unlike that in the html5ever crate (which is private and used via ::html5ever::serialize::serialize()), tries hard to minify HTML and make it compression-friendly. Use this struct directly if you need to serialize multiple nodes or doms to one writer, or control when flushing of the output writer should occur. Otherwise, use the trait Minify.

This serializer will:-

  • write value-omitted, quote-less and both single- and double-quoted attributes to minimize their length.
  • omit opening and closing tags as permitted, optionally retaining those needed for AMP pages.
  • converts element names, attribute names and DTD names to ASCII lower-case.
  • will not write out text nodes consisting entirely of inter-element whitespace.
  • will normalize inter-element whitespace sequences in text nodes, except when within a , , or
     element, unless collapse_whitespace is explicitly set to false.
  • will correctly write DTDs with public and system ids, unlike the regular one in html5ever.
  • will not escape the backtick (grave) ``` in attribute values. At one time Internet Explorer used to use this as a third way to quote attribute values.

The serializer has a small number of limitations:-

  • it always escapes ampersands & (and less-than < in raw text) where escaping is required even though there are rare places they could be left unescaped.
  • does not differentiate between the different kinds of text blocks (template, etc) beyond can-be-escaped and does-not-need-to-be-escaped.
  • does not reorder class names or attributes for possibly better compression.

Methods

impl<W: Write> UltraMinifyingHtmlSerializer<W>
[src]

[src]

Creates a new writer. If creating AMP pages, set html_head_and_body_tags_are_optional to false. To preserve comments, set preserve_comments to true. To preserve processing instructions, set preserve_processing_instructions to true.

[src]

Serializes a HTML document object model. collapse_whitespace should normally by true. If a <pre>, <code>, <samp>, or <kbd> element is encountered, it is set to false. Output is flushed after serialization finishes.

[src]

Serializes a HTML document object model node. Can be called repeatedly. collapse_whitespace should normally by true. If a <pre>, <code>, <samp>, or <kbd> element is encountered, it is set to false. If serializing HTML fragments, make flush_when_serialized true for each fragment serialized.

Trait Implementations

impl<W: Debug + Write> Debug for UltraMinifyingHtmlSerializer<W>
[src]

[src]

Formats the value using the given formatter. Read more

impl<W: Clone + Write> Clone for UltraMinifyingHtmlSerializer<W>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<W> Send for UltraMinifyingHtmlSerializer<W> where
    W: Send

impl<W> Sync for UltraMinifyingHtmlSerializer<W> where
    W: Sync