From 30487d2688af1fa67b2e438c40f3fce3652c9bdb Mon Sep 17 00:00:00 2001 From: Sylvain Gougouzian Date: Wed, 17 Apr 2024 18:09:36 +0200 Subject: [PATCH] feat: :sparkles: manage long title --- index.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index ce0a0f6..87c6cbd 100644 --- a/index.ts +++ b/index.ts @@ -50,21 +50,30 @@ if (argv.length > 2) { position: number ) => { const lines: TalkRow[] = []; + let titleSplit: string[] = ( + title + .trim() + .replace(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, "") + .match(/.{1,100}/g) as string[] + ).map((text) => text.padEnd(100, " ")); speakers.forEach((uid: string, i: number) => { if (i === 0) lines.push({ position: position + 1, - title: title - .replace(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, "") - .trim(), + title: titleSplit.shift(), format: formatsHash.get(formats), speakers: speakerHash.get(uid), rating: Number(rating.toFixed(2)), loves, hates, }); - else lines.push({ speakers: speakerHash.get(uid) }); + else + lines.push({ + title: titleSplit.shift() ?? "", + speakers: speakerHash.get(uid), + }); }); + titleSplit.forEach((title) => lines.push({ title })); lines.push({}); return lines; }