Enchance internal link by adding page scanner. Fixes #87.
This commit is contained in:
parent
12af85ee82
commit
70f9c398cc
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added a class to the search term highlighting to aid theming (#92)
|
- Added a class to the search term highlighting to aid theming (#92)
|
||||||
|
- Check for pages with various uppercased letter combinations for matching pages (#87)
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
- Made the background of tags slightly lighter (#91)
|
- Made the background of tags slightly lighter (#91)
|
|
@ -5028,15 +5028,26 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
|
|
||||||
if(preg_match('/^\[\[([^\]]*)\]\]/', $fragment["text"], $matches))
|
if(preg_match('/^\[\[([^\]]*)\]\]/', $fragment["text"], $matches))
|
||||||
{
|
{
|
||||||
$display = $linkPage = $matches[1];
|
$display = $linkPage = trim($matches[1]);
|
||||||
if(strpos($matches[1], "|"))
|
if(strpos($matches[1], "|"))
|
||||||
{
|
{
|
||||||
// We have a bar character
|
// We have a bar character
|
||||||
$parts = explode("|", $matches[1], 2);
|
$parts = explode("|", $matches[1], 2);
|
||||||
$linkPage = $parts[0];
|
$linkPage = trim($parts[0]); // The page to link to
|
||||||
$display = $parts[1];
|
$display = trim($parts[1]); // The text to display
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the page doesn't exist, check varying different
|
||||||
|
// capitalisations to see if it exists under some variant.
|
||||||
|
if(empty($pageindex->$linkPage))
|
||||||
|
{
|
||||||
|
if(!empty($pageindex->{ucfirst($linkPage)}))
|
||||||
|
$linkPage = ucfirst($linkPage);
|
||||||
|
else if(!empty($pageindex->{ucwords($linkPage)}))
|
||||||
|
$linkPage = ucwords($linkPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Construct the full url
|
// Construct the full url
|
||||||
$linkUrl = str_replace(
|
$linkUrl = str_replace(
|
||||||
"%s", rawurlencode($linkPage),
|
"%s", rawurlencode($linkPage),
|
|
@ -203,7 +203,7 @@
|
||||||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
"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.",
|
"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",
|
"id": "parser-parsedown",
|
||||||
"lastupdate": 1464942369,
|
"lastupdate": 1471599779,
|
||||||
"optional": false
|
"optional": false
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -299,15 +299,26 @@ class PeppermintParsedown extends ParsedownExtra
|
||||||
|
|
||||||
if(preg_match('/^\[\[([^\]]*)\]\]/', $fragment["text"], $matches))
|
if(preg_match('/^\[\[([^\]]*)\]\]/', $fragment["text"], $matches))
|
||||||
{
|
{
|
||||||
$display = $linkPage = $matches[1];
|
$display = $linkPage = trim($matches[1]);
|
||||||
if(strpos($matches[1], "|"))
|
if(strpos($matches[1], "|"))
|
||||||
{
|
{
|
||||||
// We have a bar character
|
// We have a bar character
|
||||||
$parts = explode("|", $matches[1], 2);
|
$parts = explode("|", $matches[1], 2);
|
||||||
$linkPage = $parts[0];
|
$linkPage = trim($parts[0]); // The page to link to
|
||||||
$display = $parts[1];
|
$display = trim($parts[1]); // The text to display
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the page doesn't exist, check varying different
|
||||||
|
// capitalisations to see if it exists under some variant.
|
||||||
|
if(empty($pageindex->$linkPage))
|
||||||
|
{
|
||||||
|
if(!empty($pageindex->{ucfirst($linkPage)}))
|
||||||
|
$linkPage = ucfirst($linkPage);
|
||||||
|
else if(!empty($pageindex->{ucwords($linkPage)}))
|
||||||
|
$linkPage = ucwords($linkPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Construct the full url
|
// Construct the full url
|
||||||
$linkUrl = str_replace(
|
$linkUrl = str_replace(
|
||||||
"%s", rawurlencode($linkPage),
|
"%s", rawurlencode($linkPage),
|
Loading…
Reference in New Issue