diff --git a/aio/tools/translator/utils.spec.ts b/aio/tools/translator/utils.spec.ts
index c08a303ae5..6e9caf785b 100644
--- a/aio/tools/translator/utils.spec.ts
+++ b/aio/tools/translator/utils.spec.ts
@@ -37,6 +37,21 @@ def`);
b
`);
});
+
+ it('拆解单行的自封闭 tag', function () {
+ const lines = normalizeLines(`
+ a
+
+ b
+`);
+ expect(lines).eql(`
+ a
+
+
+
+ b
+`);
+ });
it('拆解多行的成对 tag', function () {
const lines = normalizeLines(`
diff --git a/aio/tools/translator/utils.ts b/aio/tools/translator/utils.ts
index f19ea7b8ce..4f7455549e 100644
--- a/aio/tools/translator/utils.ts
+++ b/aio/tools/translator/utils.ts
@@ -53,8 +53,10 @@ export function normalizeLines(text: string): string {
text = text.replace(hxPattern, '\n$1\n\n');
const leadHxPattern = /^( *#.*)\n/g;
text = text.replace(leadHxPattern, '$1\n\n');
- const oneLinePairedTagPattern = /(\n * \n]*>[^<\n]*<\/div> *\n)/g;
- text = text.replace(oneLinePairedTagPattern, '\n\n$1\n\n');
+ const oneLinePairedTagPattern = /\n( *)<(p|code-example|div)( ?[^> \n]*)>([^<\n]*)<\/\2>( *)\n/g;
+ text = text.replace(oneLinePairedTagPattern, '\n\n$1<$2$3>$4$2>$5\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;
text = text.replace(multiLinePairedTagPattern, '\n\n$1<$2$3>\n\n$4\n\n$5$2>$6\n\n');
const multipleBlankLinePattern = /\n\s*\n+/g;