HtmlWithLimit in rustdoc::html::length_limit - Rust (original) (raw)
Struct HtmlWithLimit
pub(super) struct HtmlWithLimit {
buf: String,
len: usize,
limit: usize,
queued_tags: Vec<&'static str>,
unclosed_tags: Vec<&'static str>,
}
Expand description
A buffer that allows generating HTML with a length limit.
This buffer ensures that:
- all tags are closed,
- tags are closed in the reverse order of when they were opened (i.e., the correct HTML order),
- no tags are left empty (e.g.,
<em></em>
) due to the length limit being reached, - all text is escaped.
A list of tags that have been requested to be opened via Self::open_tag()but have not actually been pushed to buf
yet. This ensures that tags are not left empty (e.g., <em></em>
) due to the length limit being reached.
A list of all tags that have been opened but not yet closed.
Create a new buffer, with a limit of length_limit
.
Finish using the buffer and get the written output. This function will close all unclosed tags for you.
Write some plain text to the buffer, escaping as needed.
This function skips writing the text if the length limit was reached and returns ControlFlow::Break.
Open an HTML tag.
Note: HTML attributes have not yet been implemented. This function will panic if called with a non-alphabetic tag_name
.
Close the most recently opened HTML tag.
Write all queued tags and add them to the unclosed_tags
list.
Close all unclosed tags.
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 88 bytes