fix: 拆解单行的 td/th

This commit is contained in:
Zhicheng Wang 2018-03-07 13:09:36 +08:00
parent 77c2e039f6
commit 73eb2d2d73
2 changed files with 8 additions and 1 deletions

View File

@ -286,7 +286,11 @@ ng generate directive highlight
`)).eql(`
<tr>
<td>abc</td>
<td>
abc
</td>
</tr>
`);

View File

@ -68,6 +68,9 @@ export function normalizeLines(text: string): string {
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');
const thTdTagPattern = /( *)<(th|td)\b( *[^>\n]*)>(.*?)<\/\2>/g;
text = text.replace(thTdTagPattern, '\n\n$1<$2$3>\n\n$1 $4\n\n$1</$2>\n\n');
const blockTagPattern = /\n( *)<(\/?)(td|th|div|code-example|code-tabs|h\d+|p|tr)\b( *[^>\n]*)>( *)(?=\n)/g;
text = text.replace(blockTagPattern, '\n\n$1<$2$3$4>$5\n');