From 4c10eb42b51f2a2eba675bfa5b8ec01b3b421815 Mon Sep 17 00:00:00 2001 From: Zhicheng Wang Date: Wed, 7 Mar 2018 09:29:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8B=86=E8=A7=A3=E5=8D=95=E8=A1=8C=20b?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aio/tools/translator/utils.spec.ts | 15 +++++++++++++++ aio/tools/translator/utils.ts | 2 ++ 2 files changed, 17 insertions(+) diff --git a/aio/tools/translator/utils.spec.ts b/aio/tools/translator/utils.spec.ts index 02ceafb58e..b17dde763c 100644 --- a/aio/tools/translator/utils.spec.ts +++ b/aio/tools/translator/utils.spec.ts @@ -101,6 +101,21 @@ def`); `); }); + it('拆解单行br', function () { + const lines = normalizeLines(` + a +
+ b +`); + expect(lines).eql(` + a + +
+ + b +`); + }); + it('拆解 @a 标记', function () { const lines = normalizeLines(` a diff --git a/aio/tools/translator/utils.ts b/aio/tools/translator/utils.ts index c48f4fae6e..b0cba68a95 100644 --- a/aio/tools/translator/utils.ts +++ b/aio/tools/translator/utils.ts @@ -59,6 +59,8 @@ export function normalizeLines(text: string): string { 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'); + const oneLineBrTagPattern = /\n( *)(
)( *)\n/g; + text = text.replace(oneLineBrTagPattern, '\n\n$1$2$3\n\n'); const atTagCommentPattern = /\n( *)({@a.*})( *)\n/g; text = text.replace(atTagCommentPattern, '\n\n$1$2$3\n\n'); const oneLineClosedTagPattern = /\n( *)<(hr|p)(\/?)>( *)\n/g;