diff --git a/lib/widgets.js b/lib/widgets.js index eb20426..d521c4f 100644 --- a/lib/widgets.js +++ b/lib/widgets.js @@ -1752,6 +1752,11 @@ function renderSegments(segments, defaultColor, fontSize, yCoord, className, mar }; } +function truncate(str, limit=200) { + if (!str) return ''; + return str.length > limit ? str.slice(0, limit) + '…' : str; +} + async function renderMarker(p) { const isCard = p.markerStyle === 'card'; const W = 600; @@ -1797,8 +1802,10 @@ async function renderMarker(p) { if (!isCard) { // BANNER LAYOUT - const titleText = p.label || p.name || 'HELLO, WORLD!'; - const subText = p.bio || p.role || 'Highlighter & sketchbook theme.'; + const titleText = escXml(truncate(p.markerTitle || p.label || p.name || 'HELLO, WORLD!', 50)); + let subText = escXml(truncate(p.markerMessage || p.bio || p.role || 'Highlighter & sketchbook theme.', p.markerLimit || 200)); + subText = subText.replace(/]*>/gi, '').replace(/<\/mark>/gi, ''); + const titleRender = renderSegmentedText(titleText, col, 26, 81, 'm-title', marginX, 30); const subRender = renderSegmentedText(subText, col, 14, 123, 'm-subtitle', marginX, 30); @@ -1851,7 +1858,9 @@ async function renderMarker(p) { return skillIcon(s, skillsX + colIdx * (iconSize + gap), skillsY, iconSize); }).join(''); - const nameText = p.name || 'Your Name'; + const nameText = escXml(truncate(p.markerTitle || p.name || 'Your Name', 50)); + const bio = (p.markerMessage || p.bio || '').trim(); + const nameRender = renderSegmentedText(nameText, col, 28, 81, 'm-title', marginX, 25); const bioLine1Render = bioLinesSegments[0] ? renderSegments(bioLinesSegments[0], col, 12, 122, 'm-body', marginX, 25) : { highlights: '', text: '' }; diff --git a/tests/widgets.test.js b/tests/widgets.test.js index 8c2e306..80d6900 100644 --- a/tests/widgets.test.js +++ b/tests/widgets.test.js @@ -220,4 +220,4 @@ describe('renderWidget', () => { expect(xml).toContain('GRADUATION'); }); }); - +});