fix: 不再拆解单行的 header 元素

This commit is contained in:
Zhicheng Wang 2018-03-24 11:31:12 +08:00
parent a4ac40b640
commit 8a17495616
2 changed files with 20 additions and 28 deletions

View File

@ -217,42 +217,36 @@ ng generate directive highlight
it('拆解多行的成对 tag', function () {
const lines = normalizeLines(`
<header>
Angular forms don't require a style library
</header>
<p>
a
</p>
<p>
</p>
`);
expect(lines).eq(`
<header>
<p>
Angular forms don't require a style library
a
</header>
</p>
<p>
</p>
`);
});
it('拆解多行的成对 tag', function () {
it('不要拆解 header', function () {
const lines = normalizeLines(`
<p>
a
</p>
<p>
</p>
<header>Angular forms don't require a style library</header>
`);
expect(lines).eq(`
<p>
a
</p>
<p>
</p>
<header>Angular forms don't require a style library</header>
`);
});

View File

@ -78,8 +78,6 @@ export function normalizeLines(text: string): string {
text = text.replace(atTagCommentPattern, '\n\n$1$2$3\n');
const oneLineClosedTagPattern = /\n( *)<(hr)(\/?)>( *)(?=\n)/g;
text = text.replace(oneLineClosedTagPattern, '\n\n$1<$2$3>$4\n');
const multiLinePairedTagPattern = /\n( *)<(header)( *[^>\n]*)>\n*(.*?)\n*( *)<\/\2>( *)(?=\n)/g;
text = text.replace(multiLinePairedTagPattern, '\n\n$1<$2$3>\n\n$4\n\n$5</$2>$6\n');
const trTagPattern = /( *)(<tr\b *[^>\n]*>)(.*)(<\/tr>)/g;
text = text.replace(trTagPattern, '\n\n$1$2\n\n$1 $3\n\n$1$4\n\n');