从TouchXML提取的独立CTidy库
将HTML数据转换为有效的XHTML
NSString* html = @"<html><body><br><br><p>Hello</p></body></html>";
NSString* xhtml = [[CTidy tidy] tidyHTMLString:html
encoding:@"UTF8"
error:&error];
NSLog(@"%@", xhtml);
输出
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Mac OS X (vers 31 October 2006 - Apple Inc. build 15.4), see www.w3.org" />
<title></title>
</head>
<body>
<br />
<br />
<p>Hello</p>
</body>
</html>
要在RubyMotion中使用CTidy,请安装以下gem
gem install motion-tidy
将以下内容添加到您的Rakefile中
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'motion-cocoapods'
require 'motion-tidy'
Motion::Project::App.setup do |app|
app.name = 'sample'
# Only needed if you have not already specifying a pods dependency
app.pods do
pod 'CTidy', '>= 0.2.0'
end
end
基于TouchXML
此代码根据2-clause BSD许可证("简化版BSD许可证"或"FreeBSD许可证")许可。