456' );
//
// root = UE.htmlparser('hello1hello2');
// equals( root.toHtml().toLowerCase(), '', '解析 | hello1hello2' );
//
// root = UE.htmlparser('hello1hello2');
// equals( root.toHtml().toLowerCase(), '', '解析hello1hello2' );
//
// root = UE.htmlparser('123');
// equals( root.toHtml().toLowerCase(), '123', '123' );
//});
test( '补全不完整li', function() {
var root = UE.htmlparser('- sdf
- sdfsdf
');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'- sdf
- sdfsdf
','补全u,em');
root = UE.htmlparser('- sdf
- jkl
');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'- sdf
- jkl
','补全li');
root = UE.htmlparser('123');
equals(root.toHtml().replace(/[ ]+>/g,'>'), '', '123--补全li的parent--ul,前面有文本' );
/*补ul的child*/
root = UE.htmlparser('123');
equals(root.toHtml().replace(/[ ]+>/g,'>'), '', '123--补全ul的child--li,前面有文本' );
/*补li开始标签*/
root = UE.htmlparser(' 123');
equals(root.toHtml().replace(/[ ]+>/g,'>'), '123', '123--删掉标签' );
});
test( '属性引号问题', function() {
var root = UE.htmlparser(' ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),' ');
root = UE.htmlparser(" ");
equals(root.toHtml().replace(/[ ]+>/g,'>'),' ');
root = UE.htmlparser(' ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),' ');
});
test( '大小写', function() {
var root = UE.htmlparser(' | ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'');
root = UE.htmlparser('- sdf
- sdfsdf
');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'- sdf
- sdfsdf
','补全u,em');
root = UE.htmlparser(' ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),' ');
});
test( '裸字', function() {
var root = UE.htmlparser('sdfasdfasdf');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'sdfasdfasdf');
});
test( '只有结束标签的情况', function() {
var root = UE.htmlparser('hello1 hello2 ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'hello1 hello2 ');
});
test( '开始标签与后面文本的空格过滤,其他不过滤inline节点之间的空格,过滤block节点之间的空格', function () {
/*inline节点之间的空格要留着*/
var root = UE.htmlparser('baidu hello ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'baidu hello ');
root = UE.htmlparser(' hello he llo2 hello ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),' hello he llo2 hello ' );
/*block节点之间的空格不要留着 这个太纠结,不必了。会把ol拆开,后面的变成ul*/
// html = ' - li_test
- li test2
';
// node = serialize.parseHTML( html );
// node = serialize.filter( node );
// equal( serialize.toHTML( node ), '- li_test
- li test2
' );
} );
/*特殊字符需要转义*/
test( '文本包含特殊字符,如尖括号', function () {
var root = UE.htmlparser('');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'<td hello', '字符转义' );
} );
test( 'br', function () {
var root = UE.htmlparser(' ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),' ', '对br不操作');
root = UE.htmlparser(' ');
equals(root.toHtml().replace(/[ ]+>/g,'>'),' ', '补充br后面的斜杠');
} );
/*考察标签之间嵌套关系*/
test( '复杂标签嵌套', function() {
var root = UE.htmlparser('hello1 hello2
hello3 hello4');
equals(root.toHtml().replace(/[ ]+>/g,'>'),'hello1 hello2
');
} );
test( 'trace 1727:过滤超链接后面的空格', function () {
var root = UE.htmlparser(' baidu ddd');
equals(root.toHtml().replace(/[ ]+>/g,'>'),' baidu ddd','过滤超链接后面的空格');
} );
//test( '转换img标签', function () {
// var root = UE.htmlparser('  ');
// var spa=ua.browser.ie==6?' orgSrc="'+te.obj[1].options.UEDITOR_HOME_URL+'themes/default/images/spacer.gif"':'';
// equals(root.toHtml().replace(/[ ]+>/g,'>'), '  ' , '转换img标签');
//} ); |
|
|
|