Skip to content

Commit

Permalink
punctuation regex for code card
Browse files Browse the repository at this point in the history
  • Loading branch information
kimprice committed Oct 8, 2024
1 parent 0fc8ae5 commit 2cdfa35
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pxtblocks/codecardRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 2cdfa35

Please sign in to comment.