We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builder::attribute_filter
static
Similar to #176 I would like to write a callback for Builder::attribute_filter which doesn't have a 'static lifetime.
'static
But I just can't figure out if this is possible. This is my current attempt: pitdicker@7c69882
And this is used to test the functionality (for fixing absolute URLs with spaces or other syntax errors):
struct CleanUrl<'a>(Option<&'a ammonia::Url>); impl<'a> AttributeFilter<'a> for CleanUrl<'a> { fn filter<'val>(&self, element: &str, attribute: &str, value: &'val str) -> Option<Cow<'val, str>> { // Fix invalid links image urls match (element, attribute) { ("a", "href") => { eprintln!("href: {}", value); Some(match self.0 { Some(base) => base.join(value), None => ammonia::Url::parse(value), }.map(|u| Cow::Owned(u.into())).unwrap_or(value.into())) } ("img", "src") => { eprintln!("src: {}", value); Some(match self.0 { Some(base) => base.join(value), None => ammonia::Url::parse(value), }.map(|u| Cow::Owned(u.into())).unwrap_or(value.into())) } _ => Some(value.into()) } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Similar to #176 I would like to write a callback for
Builder::attribute_filter
which doesn't have a'static
lifetime.But I just can't figure out if this is possible. This is my current attempt: pitdicker@7c69882
And this is used to test the functionality (for fixing absolute URLs with spaces or other syntax errors):
The text was updated successfully, but these errors were encountered: