Sanitize markup by adding, changing or removing tags, using the xrb stream processor (which has a naive C implementation).
I use the sanitize gem and generally it's great. However, it's performance can be an issue and additionally, it doesn't preserve tag namespaces when parsing fragments due to how Nokogiri works internally. This is a problem when processing content destined for utopia since it heavily depends on tag namespaces.
In my informal testing, this gem is about ~50x faster than the sanitize gem when generating plain text.
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
Warming up --------------------------------------
Sanitize 438.000 i/100ms
XRB::Sanitize 7.935k i/100ms
Calculating -------------------------------------
Sanitize 4.365k (± 0.1%) i/s - 21.900k in 5.017157s
XRB::Sanitize 78.670k (± 0.1%) i/s - 396.750k in 5.043233s
Comparison:
XRB::Sanitize: 78669.9 i/s
Sanitize: 4365.0 i/s - 18.02x slower
Please see the project documentation for more details.
- Getting Started - This guide explains how to get started with the
XRB::Sanitize
gem.
We welcome contributions to this project.
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature
). - Commit your changes (
git commit -am 'Add some feature'
). - Push to the branch (
git push origin my-new-feature
). - Create new Pull Request.
This project uses the Developer Certificate of Origin. All contributors to this project must agree to this document to have their contributions accepted.
This project is governed by the Contributor Covenant. All contributors and participants agree to abide by its terms.