nh3 icon indicating copy to clipboard operation
nh3 copied to clipboard

More ammonia builder options

Open gsmedley opened this issue 8 months ago • 5 comments
trafficstars

There are some ammonia builder options it would be really nice to have:

  • add_tag (Add additonal whitelisted tags without overwriting old ones.)
  • filter_style_properties (Only allows the specified properties in style attributes.)

gsmedley avatar Mar 14 '25 08:03 gsmedley

First off, thank you for this most useful library!

I agree with @gsmedley that some of the new ammonia options would come in quite handy, especially filter_style_properties (https://github.com/rust-ammonia/ammonia/pull/208)

zerolab avatar Apr 01 '25 20:04 zerolab

The current API does not scale well with more ammonia options, we should refactor it first.

messense avatar May 22 '25 01:05 messense

Do you already have a vision for a new API?

xmo-odoo avatar Oct 06 '25 11:10 xmo-odoo

we could have a Builder that builds a Cleaner, something like:

cleaner = Builder()
    .tags({"a", "div"})
    .url_schemes({"http://", "https://"})
    .build()
cleaner.clean(html)

messense avatar Oct 07 '25 03:10 messense

Ah so more something closer to upstream ammonia's behaviour?

xmo-odoo avatar Oct 08 '25 11:10 xmo-odoo