LoofahHTML代码清理库
Loofah 是一个 HTML 代码清理库,它可以修复被中断的HTML标签。
示例代码:
doc = Loofah.fragment(unsafe_html) # returns a Nokogiri document ...
doc.scrub!(:prune) # ... with one extra method
doc.to_s # => "ohai! <div>div is safe</div> "
doc.text # => "ohai! div is safe "
评论