Struct matrix_sdk::ruma::html::Html
source · pub struct Html { /* private fields */ }
Expand description
An HTML fragment.
To get the serialized HTML, use its Display
implementation. Due to the fact that the HTML is
parsed, note that malformed HTML and comments will be stripped from the output.
Implementations§
source§impl Html
impl Html
sourcepub fn parse(string: &str) -> Html
pub fn parse(string: &str) -> Html
Construct a new Html
by parsing the given string.
This is infallible, any error encountered while parsing the HTML is logged with
tracing::debug!
.
sourcepub fn sanitize(&self)
pub fn sanitize(&self)
Sanitize this HTML according to the Matrix specification.
This is equivalent to calling Self::sanitize_with()
with a config
value of
SanitizerConfig::compat().remove_reply_fallback()
.
sourcepub fn sanitize_with(&self, config: &SanitizerConfig)
pub fn sanitize_with(&self, config: &SanitizerConfig)
Sanitize this HTML according to the given configuration.
sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Whether the root node of the HTML has children.
sourcepub fn first_child(&self) -> Option<NodeRef>
pub fn first_child(&self) -> Option<NodeRef>
The first child node of the root node of the HTML.
Returns None
if the root node has no children.
sourcepub fn last_child(&self) -> Option<NodeRef>
pub fn last_child(&self) -> Option<NodeRef>
The last child node of the root node of the HTML .
Returns None
if the root node has no children.
Trait Implementations§
source§impl Serialize for Html
impl Serialize for Html
source§fn serialize<S>(
&self,
serializer: &mut S,
traversal_scope: TraversalScope,
) -> Result<(), Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: &mut S,
traversal_scope: TraversalScope,
) -> Result<(), Error>where
S: Serializer,
source§impl TreeSink for Html
impl TreeSink for Html
§type Handle = NodeRef
type Handle = NodeRef
Handle
is a reference to a DOM node. The tree builder requires
that a Handle
implements Clone
to get another reference to
the same node.type ElemName<'a> = ExpandedName<'a>
source§fn finish(self) -> <Html as TreeSink>::Output
fn finish(self) -> <Html as TreeSink>::Output
source§fn parse_error(&self, msg: Cow<'static, str>)
fn parse_error(&self, msg: Cow<'static, str>)
source§fn elem_name<'a>(
&'a self,
target: &'a <Html as TreeSink>::Handle,
) -> ExpandedName<'a>
fn elem_name<'a>( &'a self, target: &'a <Html as TreeSink>::Handle, ) -> ExpandedName<'a>
source§fn create_element(
&self,
name: QualName,
attrs: Vec<Attribute>,
_flags: ElementFlags,
) -> <Html as TreeSink>::Handle
fn create_element( &self, name: QualName, attrs: Vec<Attribute>, _flags: ElementFlags, ) -> <Html as TreeSink>::Handle
source§fn create_comment(&self, _text: Tendril<UTF8>) -> <Html as TreeSink>::Handle
fn create_comment(&self, _text: Tendril<UTF8>) -> <Html as TreeSink>::Handle
source§fn create_pi(
&self,
_target: Tendril<UTF8>,
_data: Tendril<UTF8>,
) -> <Html as TreeSink>::Handle
fn create_pi( &self, _target: Tendril<UTF8>, _data: Tendril<UTF8>, ) -> <Html as TreeSink>::Handle
source§fn append(
&self,
parent: &<Html as TreeSink>::Handle,
child: NodeOrText<<Html as TreeSink>::Handle>,
)
fn append( &self, parent: &<Html as TreeSink>::Handle, child: NodeOrText<<Html as TreeSink>::Handle>, )
source§fn append_based_on_parent_node(
&self,
element: &<Html as TreeSink>::Handle,
prev_element: &<Html as TreeSink>::Handle,
child: NodeOrText<<Html as TreeSink>::Handle>,
)
fn append_based_on_parent_node( &self, element: &<Html as TreeSink>::Handle, prev_element: &<Html as TreeSink>::Handle, child: NodeOrText<<Html as TreeSink>::Handle>, )
source§fn append_doctype_to_document(
&self,
_name: Tendril<UTF8>,
_public_id: Tendril<UTF8>,
_system_id: Tendril<UTF8>,
)
fn append_doctype_to_document( &self, _name: Tendril<UTF8>, _public_id: Tendril<UTF8>, _system_id: Tendril<UTF8>, )
DOCTYPE
element to the Document
node.source§fn get_template_contents(
&self,
target: &<Html as TreeSink>::Handle,
) -> <Html as TreeSink>::Handle
fn get_template_contents( &self, target: &<Html as TreeSink>::Handle, ) -> <Html as TreeSink>::Handle
source§fn same_node(
&self,
x: &<Html as TreeSink>::Handle,
y: &<Html as TreeSink>::Handle,
) -> bool
fn same_node( &self, x: &<Html as TreeSink>::Handle, y: &<Html as TreeSink>::Handle, ) -> bool
source§fn set_quirks_mode(&self, _mode: QuirksMode)
fn set_quirks_mode(&self, _mode: QuirksMode)
source§fn append_before_sibling(
&self,
sibling: &<Html as TreeSink>::Handle,
new_node: NodeOrText<<Html as TreeSink>::Handle>,
)
fn append_before_sibling( &self, sibling: &<Html as TreeSink>::Handle, new_node: NodeOrText<<Html as TreeSink>::Handle>, )
source§fn add_attrs_if_missing(
&self,
target: &<Html as TreeSink>::Handle,
attrs: Vec<Attribute>,
)
fn add_attrs_if_missing( &self, target: &<Html as TreeSink>::Handle, attrs: Vec<Attribute>, )
source§fn remove_from_parent(&self, target: &<Html as TreeSink>::Handle)
fn remove_from_parent(&self, target: &<Html as TreeSink>::Handle)
source§fn reparent_children(
&self,
node: &<Html as TreeSink>::Handle,
new_parent: &<Html as TreeSink>::Handle,
)
fn reparent_children( &self, node: &<Html as TreeSink>::Handle, new_parent: &<Html as TreeSink>::Handle, )
source§fn mark_script_already_started(&self, _node: &Self::Handle)
fn mark_script_already_started(&self, _node: &Self::Handle)
<script>
as “already started”.source§fn pop(&self, _node: &Self::Handle)
fn pop(&self, _node: &Self::Handle)
source§fn associate_with_form(
&self,
_target: &Self::Handle,
_form: &Self::Handle,
_nodes: (&Self::Handle, Option<&Self::Handle>),
)
fn associate_with_form( &self, _target: &Self::Handle, _form: &Self::Handle, _nodes: (&Self::Handle, Option<&Self::Handle>), )
source§fn is_mathml_annotation_xml_integration_point(
&self,
_handle: &Self::Handle,
) -> bool
fn is_mathml_annotation_xml_integration_point( &self, _handle: &Self::Handle, ) -> bool
source§fn set_current_line(&self, _line_number: u64)
fn set_current_line(&self, _line_number: u64)
source§fn complete_script(&self, _node: &Self::Handle) -> NextParserState
fn complete_script(&self, _node: &Self::Handle) -> NextParserState
script
element is complete.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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more