function pwg_nl2br useless ? #2191

Open
opened 2026-10-05 01:09:12 +02:00 by adam · 3 comments
Owner
In regard of: https://fr.piwigo.org/forum/viewtopic.php?pid=243798#p243798 <!-- github-sync-id:3941157831 -->
Author
Owner

This looks promising in my opinion :

  // Check if content already contains HTML tags
  // Match opening tags like <p>, <br>, <div>, etc.
  if (preg_match('/<[a-z][\w-]*(?:\s[^>]*)?>/i', $string))
  {
    // Content has HTML, don't add <br>
    return $string;
  }
This looks promising in my opinion : ``` // Check if content already contains HTML tags // Match opening tags like <p>, <br>, <div>, etc. if (preg_match('/<[a-z][\w-]*(?:\s[^>]*)?>/i', $string)) { // Content has HTML, don't add <br> return $string; } ``` <!-- github-comment-id:4229288742 -->
Author
Owner

Forget, it's AI bullshit.

Forget, it's AI bullshit. <!-- github-comment-id:4229292609 -->
Author
Owner

I don't care. I don't reject AI "by default". The useless addition of <br> exists. I think detecting HTML is a good solution. Period.

I don't care. I don't reject AI "by default". The useless addition of `<br>` exists. I think detecting HTML is a good solution. Period. <!-- github-comment-id:4229296513 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2191