Skip to content
Merged
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
9 changes: 8 additions & 1 deletion src/js/modules/productcomments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ class ProductCommentsListing {
});
}

private static formatCommentContent(content: string): string {
if (!content) return '';

// Convert line breaks to <br> tags without HTML encoding special characters
return content.replace(/\r\n|\r|\n/g, '<br>');
}

private static addComment(comment: CommentData): void {
const {commentsList} = ProductCommentsElements;

Expand All @@ -497,7 +504,7 @@ class ProductCommentsListing {
commentTemplate = commentTemplate.replace(/@CUSTOMER_NAME@/g, customerName);
commentTemplate = commentTemplate.replace(/@COMMENT_DATE@/g, comment.date_add);
commentTemplate = commentTemplate.replace(/@COMMENT_TITLE@/g, comment.title);
commentTemplate = commentTemplate.replace(/@COMMENT_COMMENT@/g, comment.content);
commentTemplate = commentTemplate.replace(/@COMMENT_COMMENT@/g, this.formatCommentContent(comment.content));
commentTemplate = commentTemplate.replace(/@COMMENT_USEFUL_ADVICES@/g, comment.usefulness.toString());
commentTemplate = commentTemplate.replace(/@COMMENT_GRADE@/g, comment.grade.toString());
commentTemplate = commentTemplate.replace(
Expand Down