| Use Case | Command | Description |
|---|---|---|
| Sanitize full HTML document | Loofah.document(html) | Parse and scrub an entire HTML document |
| Sanitize HTML fragment | Loofah.fragment(html) | Parse and scrub an HTML fragment |
| Scrub document with custom scrubber | Loofah.scrub_document(html, scrubber) | Apply a custom scrubber to an HTML document |
| Scrub fragment with custom scrubber | Loofah.scrub_fragment(html, scrubber) | Apply a custom scrubber to an HTML fragment |
| Remove extra whitespace | Loofah.remove_extraneous_whitespace(doc) | Strip unnecessary whitespace from a document |
Loofah.document and Loofah.fragment accept any IO object 💾 in addition to accepting a string. That IO object could be a file, or a socket, or a StringIO, or anything that responds to read and close. Which makes it particularly easy to sanitize mass quantities of docs.
VERSION — The version of Loofah you are usingdocumentfragmentremove_extraneous_whitespacescrub_documentscrub_fragmentscrub_xml_documentscrub_xml_fragmentxml_documentxml_fragmentGenerated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-28 01:04 @216.73.217.25
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format