Skip to content

agentine/blanch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blanch

Drop-in replacement for bleach, the deprecated HTML sanitization library.

Features

  • Same API as bleach (clean, linkify, Cleaner, Linker, CSSSanitizer)
  • Zero dependencies — uses html.parser from stdlib
  • Python 3.10+
  • Full type annotations

Installation

pip install blanch

Usage

import blanch

# Sanitize HTML
blanch.clean("<script>alert('xss')</script><b>hello</b>")
# '&lt;script&gt;alert(\'xss\')&lt;/script&gt;<b>hello</b>'

# Linkify URLs
blanch.linkify("Visit https://example.com")
# 'Visit <a href="https://example.com" rel="nofollow">https://example.com</a>'

Migrating from bleach

# Option 1: Replace import
# Before: import bleach
import blanch as bleach

# Option 2: Use compatibility layer
import blanch.compat.bleach as bleach

License

MIT

About

Drop-in replacement for bleach HTML sanitization library. Zero dependencies, Python 3.10+.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors