Skip to content

Commit

Permalink
Match punctuation for code card descriptions (#10221)
Browse files Browse the repository at this point in the history
* punctuation regex for code card

* Update pxtblocks/codecardRenderer.ts

Co-authored-by: Sarah Rietkerk <[email protected]>

---------

Co-authored-by: Sarah Rietkerk <[email protected]>
  • Loading branch information
kimprice and srietkerk authored Oct 12, 2024
1 parent b56d49a commit f2c9428
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 = /((?:\.{1,3})|[\!\?…])/;
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 f2c9428

Please sign in to comment.