pub enum HTML {
Empty,
Tag(Rc<Tag>),
Sequence(Rc<[HTML]>),
Text(Rc<str>),
Whitespace,
RawNewline,
}
Expand description
Some HTML content, possibly empty. HTML content is classified as either “block”, “inline” or “empty”.
HTML values are normalised so sequences are not empty or a single item, and they do not contain nested sequences. Additionally, text is not empty, or a single space or newline character. This is necessary in order to ensure consistent matching of HTML sequences, and to test equality of HTML values.
Variants§
Empty
Represents the absence of any HTML content.
Tag(Rc<Tag>)
An HTML tag.
Sequence(Rc<[HTML]>)
A sequence of HTML content. The sequence is normalised so that it does
not include Empty
values, consecutive text nodes or nested sequences,
and its length is at least 2.
Text(Rc<str>)
Raw text content. May contain special characters which will need to be escaped when rendering to HTML.
Whitespace
A single space. Sequences of whitespace are collapsed to this.
RawNewline
A literal newline. This is only useful in pre-formatted content, such
as a <pre>
tag; otherwise it is equivalent to whitespace.
Implementations§
Source§impl HTML
impl HTML
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Indicates whether this HTML item is HTML::Empty
. Whitespace and
literal newlines are not considered to be empty.
Sourcepub fn is_block(&self) -> bool
pub fn is_block(&self) -> bool
Indicates whether this HTML item is block-level content, or otherwise does not need to be wrapped in a block-level element. Empty content is not considered to be block-level.
Sourcepub fn is_inline(&self) -> bool
pub fn is_inline(&self) -> bool
Indicates whether this HTML item is inline content which may need to be wrapped in a block-level element. Empty content is not considered to be inline, since it doesn’t need to be wrapped.
Sourcepub fn is_whitespace(&self) -> bool
pub fn is_whitespace(&self) -> bool
Indicates whether this HTML item is whitespace, including a literal
newline or HTML::Empty
.
Trait Implementations§
Source§impl FromIterator<HTML> for HTML
impl FromIterator<HTML> for HTML
Source§fn from_iter<T: IntoIterator<Item = HTML>>(iter: T) -> HTML
fn from_iter<T: IntoIterator<Item = HTML>>(iter: T) -> HTML
Converts a sequence of HTML items into one normalised HTML item. Empty
items are dropped, consecutive text nodes are merged, and nested
sequences are flattened. The result is then wrapped in an HTML::Sequence
only if there are at least two items.
Source§impl PartialEq for HTML
impl PartialEq for HTML
impl Eq for HTML
Auto Trait Implementations§
impl Freeze for HTML
impl RefUnwindSafe for HTML
impl !Send for HTML
impl !Sync for HTML
impl Unpin for HTML
impl UnwindSafe for HTML
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.