fix: 拆解单行 br

This commit is contained in:
Zhicheng Wang 2018-03-07 09:29:06 +08:00
parent 8dcffab9c8
commit 4c10eb42b5
2 changed files with 17 additions and 0 deletions

View File

@ -101,6 +101,21 @@ def`);
`);
});
it('拆解单行br', function () {
const lines = normalizeLines(`
a
<br class="clear">
b
`);
expect(lines).eql(`
a
<br class="clear">
b
`);
});
it('拆解 @a 标记', function () {
const lines = normalizeLines(`
a

View File

@ -59,6 +59,8 @@ export function normalizeLines(text: string): string {
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;
text = text.replace(oneLineCommentPattern, '\n\n$1$2$3\n\n');
const oneLineBrTagPattern = /\n( *)(<br class="clear">)( *)\n/g;
text = text.replace(oneLineBrTagPattern, '\n\n$1$2$3\n\n');
const atTagCommentPattern = /\n( *)({@a.*})( *)\n/g;
text = text.replace(atTagCommentPattern, '\n\n$1$2$3\n\n');
const oneLineClosedTagPattern = /\n( *)<(hr|p)(\/?)>( *)\n/g;