[aur-dev] [PATCH v2] Fix issue with ending delimiter of code block

Marcel Korpel marcel.korpel at gmail.com
Sat Jul 11 18:35:59 UTC 2015


When a comment ends with ``` without a newline character, the delimiter
is not correctly recognized. Fix by adding a newline character.

Signed-off-by: Marcel Korpel <marcel.korpel at gmail.com>
---
Change since v1:
* Fix commit message

 web/lib/aur.inc.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/web/lib/aur.inc.php b/web/lib/aur.inc.php
index d0c8c98..0073cd8 100644
--- a/web/lib/aur.inc.php
+++ b/web/lib/aur.inc.php
@@ -612,6 +612,12 @@ function parse_comment($comment) {
 	$md_code_fragment_delimiter = '/(`)/';
 	$md_code_fragment_active = false;
 
+	// repair special case where the last instance of ``` doesn't end with
+	// a newline character
+	if (substr($comment, -3) == '```') {
+		$comment .= "\n";
+	}
+
 	$blocks = preg_split($md_codeblock_delimiter, $comment, -1,
 		PREG_SPLIT_DELIM_CAPTURE);
 
-- 
2.4.5


More information about the aur-dev mailing list