[aur-dev] [PATCH] Don't add <br> at the end of a comment

Marcel Korpel marcel.korpel at gmail.com
Sat Jul 11 22:12:47 UTC 2015


If the comment ends with a newline, a superfluous <br> is inserted,
resulting in extra whitespace at the end of the comment.

Signed-off-by: Marcel Korpel <marcel.korpel at gmail.com>
---
 web/lib/aur.inc.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index 7e85959..6c0532c 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -614,8 +614,9 @@ function parse_comment($comment) {
 
 	$html = '';
 	$lines = preg_split('/\R/', $comment);
+	$len = count($lines);
 
-	foreach ($lines as $line) {
+	foreach ($lines as $key => $line) {
 		if ($line == $md_codeblock_delimiter) {
 			if ($md_codeblock_active) {
 				$html .= '</code></pre><p>';
@@ -654,7 +655,10 @@ function parse_comment($comment) {
 					},
 					$line);
 
-				$html .= $line . "<br />\n";
+				$html .= $line;
+				if ($key < $len - 1) {
+					$html .= "<br />\n";
+				}
 			}
 		}
 	}
-- 
2.4.5


More information about the aur-dev mailing list