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

This commit is contained in:
Zhicheng Wang 2018-03-07 10:13:16 +08:00
parent 400a6d0b8e
commit 43e7e9fe8c

View File

@ -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');