fix: 解决其他元素的拆解问题
This commit is contained in:
parent
f89d728818
commit
4ddf7348a4
|
@ -155,6 +155,34 @@ def`);
|
|||
|
||||
</header>
|
||||
|
||||
`);
|
||||
});
|
||||
|
||||
it('拆解多行的成对 tag', function () {
|
||||
const lines = normalizeLines(`
|
||||
<p>
|
||||
a
|
||||
</p>
|
||||
|
||||
<p>
|
||||
一
|
||||
</p>
|
||||
|
||||
`);
|
||||
expect(lines).eq(`
|
||||
|
||||
<p>
|
||||
|
||||
a
|
||||
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
||||
一
|
||||
|
||||
</p>
|
||||
|
||||
`);
|
||||
});
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ export function normalizeLines(text: string): string {
|
|||
text = text.replace(atTagCommentPattern, '\n\n$1$2$3\n\n');
|
||||
const oneLineClosedTagPattern = /\n( *)<(hr|p)(\/?)>( *)\n/g;
|
||||
text = text.replace(oneLineClosedTagPattern, '\n\n$1<$2$3>$4\n\n');
|
||||
const multiLinePairedTagPattern = /\n( *)<(header)( *[^> \n]*)>\n?(.*?)\n?( *)<\/\2>( *)\n/g;
|
||||
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');
|
||||
|
||||
const multiLineCodePattern = /\n( *)```( *)\n/g;
|
||||
|
|
Loading…
Reference in New Issue