fix: 拆解单行 li
This commit is contained in:
parent
4c10eb42b5
commit
4c6b614064
|
@ -210,6 +210,19 @@ def`);
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
it('拆解独行的 li', function () {
|
||||||
|
expect(normalizeLines(`
|
||||||
|
<li><span>abc</span></li>
|
||||||
|
`)).eql(`
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span>abc</span>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
it('不要拆解行内的 html tag', function () {
|
it('不要拆解行内的 html tag', function () {
|
||||||
|
|
|
@ -55,7 +55,7 @@ export function normalizeLines(text: string): string {
|
||||||
text = text.replace(leadHxPattern, '$1\n\n');
|
text = text.replace(leadHxPattern, '$1\n\n');
|
||||||
const oneLinePairedTagPattern = /\n( *)<(p|code-example|div|h\d+|a)( ?[^> \n]*)>([^<\n]*)<\/\2>( *)\n/g;
|
const oneLinePairedTagPattern = /\n( *)<(p|code-example|div|h\d+|a)( ?[^> \n]*)>([^<\n]*)<\/\2>( *)\n/g;
|
||||||
text = text.replace(oneLinePairedTagPattern, '\n\n$1<$2$3>$4</$2>$5\n\n');
|
text = text.replace(oneLinePairedTagPattern, '\n\n$1<$2$3>$4</$2>$5\n\n');
|
||||||
const oneLineThTdTagPattern = /\n( *)<(th|td)( ?[^> \n]*)>([^<\n]*)<\/\2>( *)\n/g;
|
const oneLineThTdTagPattern = /\n( *)<(th|td|li)( ?[^> \n]*)>(.*)<\/\2>( *)\n/g;
|
||||||
text = text.replace(oneLineThTdTagPattern, '\n\n$1<$2$3>\n\n$1$4\n\n$1</$2>$5\n\n');
|
text = text.replace(oneLineThTdTagPattern, '\n\n$1<$2$3>\n\n$1$4\n\n$1</$2>$5\n\n');
|
||||||
const oneLineCommentPattern = /\n( *)(<!--.*-->)( *)\n/g;
|
const oneLineCommentPattern = /\n( *)(<!--.*-->)( *)\n/g;
|
||||||
text = text.replace(oneLineCommentPattern, '\n\n$1$2$3\n\n');
|
text = text.replace(oneLineCommentPattern, '\n\n$1$2$3\n\n');
|
||||||
|
|
Loading…
Reference in New Issue