INNER CODE UNIT · JavaScript
truncateDescription
cporter202/agentic-ai-apis · settings/generate_readme_clean.js:71
function truncateDescription(description, maxLength = 200) {
if (!description || description.length <= maxLength) {
return description || '-';
}
let cutPoint = maxLength;
const lastSpace = description.lastIndexOf(' ', maxLength);
if (lastSpace > maxLength * 0.8) {
cutPoint = lastSpace;
}
return `${description.substring(0, cutPoint).trim()}...`;
}
function sanitizeTableValue(value) {
return (value || '').replace(/\|/g, '|').replace(/\n/g, ' ');
}