fix: 为单行拆解成多行结果增加缩进

This commit is contained in:
Zhicheng Wang 2018-03-07 10:13:16 +08:00
parent 400a6d0b8e
commit 43e7e9fe8c
1 changed files with 2 additions and 2 deletions

View File

@ -57,7 +57,7 @@ export function normalizeLines(text: string): string {
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');
const oneLineThTdTagPattern = /\n( *)<(th|td|li)( ?[^> \n]*)>(.*)<\/\2>( *)/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;
text = text.replace(oneLineCommentPattern, '\n\n$1$2$3\n\n');
const oneLineBrTagPattern = /\n( *)(<br class="clear">)( *)\n/g;
@ -67,7 +67,7 @@ export function normalizeLines(text: string): string {
const oneLineClosedTagPattern = /\n( *)<(hr|p)(\/?)>( *)\n/g;
text = text.replace(oneLineClosedTagPattern, '\n\n$1<$2$3>$4\n\n');
const multiLinePairedTagPattern = /\n( *)<(header|p)( *[^> \n]*)>\n*(.*?)\n*( *)<\/\2>( *)\n/g;
text = text.replace(multiLinePairedTagPattern, '\n\n$1<$2$3>\n\n$4\n\n$5</$2>$6\n\n');
text = text.replace(multiLinePairedTagPattern, '\n\n$1<$2$3>\n\n$1 $4\n\n$1</$2>$6\n\n');
const blockTagPattern = /\n( *)<(\/?)(td|th|div)( *[^> \n]*)>( *)\n/g;
text = text.replace(blockTagPattern, '\n\n$1<$2$3$4>$5\n\n');