diff --git a/aio/tools/translator/utils.spec.ts b/aio/tools/translator/utils.spec.ts index 2a3f9c8bf4..7475b28a37 100644 --- a/aio/tools/translator/utils.spec.ts +++ b/aio/tools/translator/utils.spec.ts @@ -155,6 +155,34 @@ def`); +`); + }); + + it('拆解多行的成对 tag', function () { + const lines = normalizeLines(` +
+ a +
+ ++ 一 +
+ +`); + expect(lines).eq(` + ++ + a + +
+ ++ + 一 + +
+ `); }); diff --git a/aio/tools/translator/utils.ts b/aio/tools/translator/utils.ts index 59d648bd70..b77b165342 100644 --- a/aio/tools/translator/utils.ts +++ b/aio/tools/translator/utils.ts @@ -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;