From 6504156508615a855ef3f582191b4b82147a7231 Mon Sep 17 00:00:00 2001
From: Tobias Diekershoff <tobias.diekershoff@gmx.net>
Date: Wed, 9 Aug 2017 16:04:53 +0200
Subject: [PATCH 1/5] add a switch to the Markdown parser for using hard line
 breaks (issue 3592)

---
 library/markdown.php | 29 +++++++++++++++++++++++++++--
 mod/admin.php        |  4 ++--
 mod/help.php         |  4 ++--
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/library/markdown.php b/library/markdown.php
index 769bdb121..61eb5951c 100644
--- a/library/markdown.php
+++ b/library/markdown.php
@@ -1,14 +1,39 @@
 <?php
+
+/**
+ * @file library/markdown.php
+ *
+ * @brief Parser for Markdown files
+ */
+
 require_once "library/php-markdown/Michelf/MarkdownExtra.inc.php";
 use \Michelf\MarkdownExtra;
 
-function Markdown($text) {
+/**
+ * @brief This function parses a text using php-markdown library to render Markdown syntax to HTML
+ *
+ * This function is using the php-markdown library by Michel Fortin to parse a 
+ * string ($text).It returns the rendered HTML code from that text. The optional 
+ * $hardbreak parameter is used to switch between inserting hard breaks after
+ * every linefeed, which is required for Diaspora compatibility, or not. The
+ * later is used for parsing documentation and README.md files.
+ *
+ * @param string $text
+ * @param boolean $hardbreak
+ * @returns string
+ */
+
+function Markdown($text, $hardbreak=true) {
 	$a = get_app();
 
 	$stamp1 = microtime(true);
 
 	$MarkdownParser = new MarkdownExtra();
-	$MarkdownParser->hard_wrap = true;
+	if ($hardbreak) {
+		$MarkdownParser->hard_wrap = true;
+	} else {
+		$MarkdownParser->hard_wrap = false;
+	}
 	$html = $MarkdownParser->transform($text);
 
 	$a->save_timestamp($stamp1, "parser");
diff --git a/mod/admin.php b/mod/admin.php
index e59baaa1d..90bc8c0fc 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -1687,7 +1687,7 @@ function admin_page_plugins(App $a) {
 		$readme=Null;
 		if (is_file("addon/$plugin/README.md")) {
 			$readme = file_get_contents("addon/$plugin/README.md");
-			$readme = Markdown($readme);
+			$readme = Markdown($readme, false);
 		} elseif (is_file("addon/$plugin/README")) {
 			$readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
 		}
@@ -1939,7 +1939,7 @@ function admin_page_themes(App $a) {
 		$readme = Null;
 		if (is_file("view/theme/$theme/README.md")) {
 			$readme = file_get_contents("view/theme/$theme/README.md");
-			$readme = Markdown($readme);
+			$readme = Markdown($readme, false);
 		} elseif (is_file("view/theme/$theme/README")) {
 			$readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
 		}
diff --git a/mod/help.php b/mod/help.php
index 1d5c831ef..95fe91c38 100644
--- a/mod/help.php
+++ b/mod/help.php
@@ -49,7 +49,7 @@ function help_content(App $a) {
 		$filename = "Home";
 		$a->page['title'] = t('Help');
 	} else {
-		$a->page['aside'] = Markdown($home);
+		$a->page['aside'] = Markdown($home, false);
 	}
 
 	if (!strlen($text)) {
@@ -60,7 +60,7 @@ function help_content(App $a) {
 				));
 	}
 
-	$html = Markdown($text);
+	$html = Markdown($text, false);
 
 	if ($filename !== "Home") {
 		// create TOC but not for home

From 29a66c8336cb127f9a927e1c5cd317f3b9fde9f2 Mon Sep 17 00:00:00 2001
From: Tobias Diekershoff <tobias.diekershoff@gmx.net>
Date: Wed, 9 Aug 2017 16:10:09 +0200
Subject: [PATCH 2/5] it is hardwrap for consistency

---
 library/markdown.php | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/library/markdown.php b/library/markdown.php
index 61eb5951c..00696d2fe 100644
--- a/library/markdown.php
+++ b/library/markdown.php
@@ -14,22 +14,22 @@ use \Michelf\MarkdownExtra;
  *
  * This function is using the php-markdown library by Michel Fortin to parse a 
  * string ($text).It returns the rendered HTML code from that text. The optional 
- * $hardbreak parameter is used to switch between inserting hard breaks after
+ * $hardwrap parameter is used to switch between inserting hard breaks after
  * every linefeed, which is required for Diaspora compatibility, or not. The
  * later is used for parsing documentation and README.md files.
  *
  * @param string $text
- * @param boolean $hardbreak
- * @returns string
+ * @param boolean $hardwrap
+ * @return string
  */
 
-function Markdown($text, $hardbreak=true) {
+function Markdown($text, $hardwrap=true) {
 	$a = get_app();
 
 	$stamp1 = microtime(true);
 
 	$MarkdownParser = new MarkdownExtra();
-	if ($hardbreak) {
+	if ($hardwrap) {
 		$MarkdownParser->hard_wrap = true;
 	} else {
 		$MarkdownParser->hard_wrap = false;

From a0ecd5ab2ec536c039986f93b44d80a4cdf086b7 Mon Sep 17 00:00:00 2001
From: Tobias Diekershoff <tobias.diekershoff@gmx.net>
Date: Wed, 9 Aug 2017 19:18:38 +0200
Subject: [PATCH 3/5] add more space

---
 library/markdown.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/library/markdown.php b/library/markdown.php
index 00696d2fe..bf7ec4095 100644
--- a/library/markdown.php
+++ b/library/markdown.php
@@ -23,7 +23,7 @@ use \Michelf\MarkdownExtra;
  * @return string
  */
 
-function Markdown($text, $hardwrap=true) {
+function Markdown($text, $hardwrap = true) {
 	$a = get_app();
 
 	$stamp1 = microtime(true);

From 147bfb05761d37eb7c8292b80ce4d22eefaee9a6 Mon Sep 17 00:00:00 2001
From: Tobias Diekershoff <tobias.diekershoff@gmx.net>
Date: Wed, 9 Aug 2017 19:19:42 +0200
Subject: [PATCH 4/5] some simplification

---
 library/markdown.php | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/library/markdown.php b/library/markdown.php
index bf7ec4095..8def53fcb 100644
--- a/library/markdown.php
+++ b/library/markdown.php
@@ -29,11 +29,7 @@ function Markdown($text, $hardwrap = true) {
 	$stamp1 = microtime(true);
 
 	$MarkdownParser = new MarkdownExtra();
-	if ($hardwrap) {
-		$MarkdownParser->hard_wrap = true;
-	} else {
-		$MarkdownParser->hard_wrap = false;
-	}
+	$MarkdownParser->hard_wrap = $hardwrap;
 	$html = $MarkdownParser->transform($text);
 
 	$a->save_timestamp($stamp1, "parser");

From e89e00856582a34be8225ed7e8950ebb83081ff2 Mon Sep 17 00:00:00 2001
From: Tobias Diekershoff <tobias.diekershoff@gmx.net>
Date: Thu, 10 Aug 2017 10:31:45 +0200
Subject: [PATCH 5/5] missing bracket

---
 mod/invite.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mod/invite.php b/mod/invite.php
index f2fae5294..0b8f5046f 100644
--- a/mod/invite.php
+++ b/mod/invite.php
@@ -132,7 +132,7 @@ function invite_content(App $a) {
 			return $o;
 		} else {
 			$linktxt = sprintf( t('To accept this invitation, please visit and register at %s.'), App::get_baseurl()
-			. "\r\n" . "\r\n" . t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks.');
+			. "\r\n" . "\r\n" . t('Friendica sites all inter-connect to create a huge privacy-enhanced social web that is owned and controlled by its members. They can also connect with many traditional social networks.'));
 		}
 	}