Struct html_sanitizer::Tag [−][src]
pub struct Tag<'a> { pub name: &'a str, pub attrs: &'a [(&'a str, &'a str)], // some fields omitted }
Represents a single HTML node. You can read the name
and attrs
properties to figure out what tag you're sanitizing.
By default all html nodes will be printed, but attributes will be stripped from a tag unless they are added with allow_attribute
and allow_attributes
.
Fields
name: &'a str
The name of the HTML tag, e.g. 'div', 'img', etc.
attrs: &'a [(&'a str, &'a str)]
The attributes of the HTML tag, e.g. ('style', 'width: 100%').
Methods
impl<'a> Tag<'a>
[src]
impl<'a> Tag<'a>
pub fn allow_attribute(&mut self, attr: String)
[src]
pub fn allow_attribute(&mut self, attr: String)
Allow the given attribute. This attribute does not have to exist in the attrs
tag.
When this HTML node gets printed, this attribute will also get printed.
pub fn allow_attributes(&mut self, attr: &[String])
[src]
pub fn allow_attributes(&mut self, attr: &[String])
Allow the given attributes. These attributes do not have to exist in the attrs
tag.
When this HTML node gets printed, these attributes will also get printed.
pub fn ignore_self_and_contents(&mut self)
[src]
pub fn ignore_self_and_contents(&mut self)
Ignore this tag. This means that the HTML Node will not be printed in the output. In addition, all the child nodes and text content will also not be printed.
pub fn ignore_self(&mut self)
[src]
pub fn ignore_self(&mut self)
Ignore this tag. This means that the HTML Node will not be printed in the output. All child nodes and text content will be printed.
pub fn rewrite_as(&mut self, new_contents: String)
[src]
pub fn rewrite_as(&mut self, new_contents: String)
Completely rewrite this tag and all it's children, replacing them by the custom string that is passed to this function.