Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(/<mark[^>]*>/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);
Expand Down Expand Up @@ -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: '' };
Expand Down
2 changes: 1 addition & 1 deletion tests/widgets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ describe('renderWidget', () => {
expect(xml).toContain('GRADUATION');
});
});

});