Ruby 1.9中的HTML整理/清理 [英] HTML tidy/cleaning in Ruby 1.9
本文介绍了Ruby 1.9中的HTML整理/清理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我正在使用RubyTidy Ruby绑定进行HTML整理,以确保我收到的HTML格式良好。目前这个库是阻止我在Ruby 1.9上获得Rails应用程序的唯一因素。有没有其他的库可以整理Ruby 1.9上的HTML?
解决方案我正在使用 Nokogiri 修复无效html:
Nokogiri: :HTML :: DocumentFragment.parse(html).to_html
I'm currently using the RubyTidy Ruby bindings for HTML tidy to make sure HTML I receive is well-formed. Currently this library is the only thing holding me back from getting a Rails application on Ruby 1.9. Are there any alternative libraries out there that will tidy up chunks of HTML on Ruby 1.9?
解决方案
I am using Nokogiri to fix invalid html:
Nokogiri::HTML::DocumentFragment.parse(html).to_html
这篇关于Ruby 1.9中的HTML整理/清理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文