From 2cdfa35444197593e888b479948c68835b6f8b36 Mon Sep 17 00:00:00 2001 From: Kim Ying <15070078+kimprice@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:23:55 -0700 Subject: [PATCH] punctuation regex for code card --- pxtblocks/codecardRenderer.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pxtblocks/codecardRenderer.ts b/pxtblocks/codecardRenderer.ts index 24204dc55de..f2116cc47f2 100644 --- a/pxtblocks/codecardRenderer.ts +++ b/pxtblocks/codecardRenderer.ts @@ -100,7 +100,13 @@ export function renderCodeCard(card: pxt.CodeCard, options: CodeCardRenderOption } if (card.description) { const descr = div(ct, 'ui description'); - const shortenedDescription = card.description.split('.')[0] + '.'; + const regex = /((?:\.\.\.)|[\!\.\?…])/; + const match = regex.exec(card.description); + let shortenedDescription = card.description + "."; + if (match) { + const punctuation = match[1]; + shortenedDescription = card.description.split(punctuation)[0] + punctuation; + } descr.appendChild(document.createTextNode(shortenedDescription)); }