From b693953a5c5dde9e4142c03b40c08f1075280424 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Sat, 25 Feb 2017 10:57:10 +0000
Subject: [PATCH] Bugfix: Include the rest of a word in internal links.

---
 Changelog.md                 | 3 ++-
 build/index.php              | 4 ++--
 module_index.json            | 2 +-
 modules/parser-parsedown.php | 6 +++---
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index fa5072e..af08bba 100755
--- a/Changelog.md
+++ b/Changelog.md
@@ -19,6 +19,7 @@
      - Added the `user_page_prefix` setting to allow customisation of where user pages should be located. Default value: `Users`
      - [Module API] Added `get_user_pagename()` and `extract_user_from_userpage()` to allo  programatic detection etc.
  - Added a `user-list` action that, well, outputs a list of users. Includes links to their respective user pages (though redlinks aren't implemented here yet).
+ - Internal links like `[[Page name]]s` will now link to the correct page in include the rest of the word. Note that this functionality _can't_ be mixed with displayy text, like this: `[[Page name|Display text]]s` - the rest of the word will be silently ignored in the link!
 
 ### Changed
  - Overhauled internal history logic - history logic is now done in core.
@@ -34,7 +35,7 @@
  - Recent changes made on different days are now displayed separately, as they should be (#112)
  - Always display footer message at the bottom of the page.
  - Trim the image url before short image url detection (#108)
- - Fxed huge issue with `contentonly` display mode.
+ - Fixed huge issue with `contentonly` display mode.
  - Improved the search engine indexing algorithm. It now shouldn't choke on certain special characters (`[]{}|`) and will treat them as word boundaries.
  - Fixed tag links at the bottom of pages for tags with a single quote (`'`) in them.
  - Correct error message when attempting to move a page
diff --git a/build/index.php b/build/index.php
index 79f32aa..7651f62 100644
--- a/build/index.php
+++ b/build/index.php
@@ -5967,9 +5967,9 @@ class PeppermintParsedown extends ParsedownExtra
 	{
 		global $pageindex, $env;
 		
-		if(preg_match('/^\[\[([^\]]*)\]\]/', $fragment["text"], $matches))
+		if(preg_match('/^\[\[([^\]]*)\]\]([^\s!?",.()\[\]{}*=+\/]*)/u', $fragment["text"], $matches))
 		{
-			$display = $linkPage = trim($matches[1]);
+			$display = $linkPage = trim($matches[1]) . trim($matches[2]);
 			if(strpos($matches[1], "|") !== false || strpos($matches[1], "¦") !== false)
 			{
 				// We have a bar character
diff --git a/module_index.json b/module_index.json
index 63bd660..c887258 100755
--- a/module_index.json
+++ b/module_index.json
@@ -239,7 +239,7 @@
         "author": "Emanuil Rusev & Starbeamrainbowlabs",
         "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
         "id": "parser-parsedown",
-        "lastupdate": 1483388764,
+        "lastupdate": 1488019684,
         "optional": false
     }
 ]
\ No newline at end of file
diff --git a/modules/parser-parsedown.php b/modules/parser-parsedown.php
index ec3b176..e880918 100644
--- a/modules/parser-parsedown.php
+++ b/modules/parser-parsedown.php
@@ -1,7 +1,7 @@
 <?php
 register_module([
 	"name" => "Parsedown",
-	"version" => "0.9.7",
+	"version" => "0.9.8",
 	"author" => "Emanuil Rusev & Starbeamrainbowlabs",
 	"description" => "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https://github.com/erusev/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
 	"id" => "parser-parsedown",
@@ -315,9 +315,9 @@ class PeppermintParsedown extends ParsedownExtra
 	{
 		global $pageindex, $env;
 		
-		if(preg_match('/^\[\[([^\]]*)\]\]/', $fragment["text"], $matches))
+		if(preg_match('/^\[\[([^\]]*)\]\]([^\s!?",.()\[\]{}*=+\/]*)/u', $fragment["text"], $matches))
 		{
-			$display = $linkPage = trim($matches[1]);
+			$display = $linkPage = trim($matches[1]) . trim($matches[2]);
 			if(strpos($matches[1], "|") !== false || strpos($matches[1], "¦") !== false)
 			{
 				// We have a bar character
