[−][src]Struct lol_html::RewriteStrSettings
Specifies settings for the rewrite_str
function.
Fields
element_content_handlers: Vec<(&'s Selector, ElementContentHandlers<'h>)>
Specifies CSS selectors and rewriting handlers for elements and their inner content.
Hint
element
, comments
and text
convenience macros can be used to construct a
(Selector, ElementContentHandlers)
tuple.
Example
use lol_html::{ElementContentHandlers, RewriteStrSettings}; let settings = RewriteStrSettings { element_content_handlers: vec! [ ( &"div[foo]".parse().unwrap(), ElementContentHandlers::default().element(|el| { // ... Ok(()) }) ), ( &"body".parse().unwrap(), ElementContentHandlers::default().comments(|c| { // ... Ok(()) }) ) ], ..RewriteStrSettings::default() };
document_content_handlers: Vec<DocumentContentHandlers<'h>>
Specifies rewriting handlers for the content without associating it to a particular CSS selector.
Refer to DocumentContentHandlers
documentation for more information.
Hint
doctype
, doc_comments
and doc_text
convenience macros can be used to construct
items of this vector.
strict: bool
If set to true
the rewriter bails out if it encounters markup that drives the HTML parser
into ambigious state.
Since the rewriter operates on a token stream and doesn't have access to a full DOM-tree, there are certain rare cases of non-conforming HTML markup which can't be guaranteed to be parsed correctly without an ability to backtrace the tree.
Therefore, due to security considerations, sometimes it's preferable to abort the rewriting process in case of such uncertainty.
One of the simplest examples of such markup is the following:
...
<select><xmp><script>"use strict";</script></select>
...
The <xmp>
element is not allowed inside the <select>
element, so in a browser the start
tag for <xmp>
will be ignored and following <script>
element will be parsed and executed.
On the other hand, the <select>
element itself can be also ignored depending on the
context in which it was parsed. In this case, the <xmp>
element will not be ignored
and the <script>
element along with its content will be parsed as a simple text inside
it.
So, in this case the parser needs an ability to backtrace the DOM-tree to figure out the correct parsing context.
Default
true
when constructed with Settings::default()
.
Trait Implementations
impl<'_, '_> Default for RewriteStrSettings<'_, '_>
[src]
impl<'h, 's> From<RewriteStrSettings<'h, 's>> for Settings<'h, 's>
[src]
fn from(settings: RewriteStrSettings<'h, 's>) -> Self
[src]
Auto Trait Implementations
impl<'h, 's> !RefUnwindSafe for RewriteStrSettings<'h, 's>
impl<'h, 's> !Send for RewriteStrSettings<'h, 's>
impl<'h, 's> !Sync for RewriteStrSettings<'h, 's>
impl<'h, 's> Unpin for RewriteStrSettings<'h, 's>
impl<'h, 's> !UnwindSafe for RewriteStrSettings<'h, 's>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,