diff --git a/aio/tools/translator/utils.spec.ts b/aio/tools/translator/utils.spec.ts index b17dde763c..927f1b207a 100644 --- a/aio/tools/translator/utils.spec.ts +++ b/aio/tools/translator/utils.spec.ts @@ -210,6 +210,19 @@ def`); +`); + }); + it('拆解独行的 li', function () { + expect(normalizeLines(` +
  • abc
  • +`)).eql(` + +
  • + +abc + +
  • + `); }); it('不要拆解行内的 html tag', function () { diff --git a/aio/tools/translator/utils.ts b/aio/tools/translator/utils.ts index b0cba68a95..a7e6046403 100644 --- a/aio/tools/translator/utils.ts +++ b/aio/tools/translator/utils.ts @@ -55,7 +55,7 @@ export function normalizeLines(text: string): string { text = text.replace(leadHxPattern, '$1\n\n'); 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$5\n\n'); - const oneLineThTdTagPattern = /\n( *)<(th|td)( ?[^> \n]*)>([^<\n]*)<\/\2>( *)\n/g; + const oneLineThTdTagPattern = /\n( *)<(th|td|li)( ?[^> \n]*)>(.*)<\/\2>( *)\n/g; text = text.replace(oneLineThTdTagPattern, '\n\n$1<$2$3>\n\n$1$4\n\n$1$5\n\n'); const oneLineCommentPattern = /\n( *)()( *)\n/g; text = text.replace(oneLineCommentPattern, '\n\n$1$2$3\n\n');