4,476
edits
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
function formatParagraphs(text) { | function formatParagraphs(text) { | ||
var paragraphs = text.split('\n').filter(function (p) { return p.trim() !== '' }); | |||
return paragraphs.map(function (p) { return '<p>' + p.trim() + '</p>'; }).join(''); | |||
} | |||
function formatCommunityCardDescriptions() { | |||
console.log("Formatting community card descriptions"); | |||
$('.community-card').each(function() { | |||
console.log("Processing a community card"); | |||
var descriptionContainer = $(this).find('.community-description'); | |||
var rawDescription = descriptionContainer.text(); | |||
console.log("Raw Description:", rawDescription); | |||
var formattedDescription = formatParagraphs(rawDescription); | |||
descriptionContainer.html(formattedDescription); | |||
// Remove empty <p> tags, including those containing only <br> | |||
descriptionContainer.find('p').each(function() { | |||
if ($(this).is(':empty') || $(this).html().trim() === '<br>') { | |||
$(this).remove(); | |||
} | |||
}); | |||
console.log("Formatted Description HTML:", descriptionContainer.html()); | |||
}); | |||
} | |||
// Check if we are on a page that requires community card formatting | |||
if ($('.community-card').length) { | |||
formatCommunityCardDescriptions(); | |||
} | |||
// Delegate the mousedown event to the '.card' elements inside the '#list' container | // Delegate the mousedown event to the '.card' elements inside the '#list' container | ||
$('#list').on('mousedown', '.card', function (event) { | $('#list').on('mousedown', '.card', function (event) { |