Document wiki relative link syntax

Summary: Also make `../` work to start relative a link so I don't have to document it as `./../path`.

Test Plan:
  - Used `./`, `../`. `./../`, and normal links (proper title pickup).
  - Used bad links (red).
  - Regenerated documentation:

{F1221692}

Reviewers: hach-que

Reviewed By: hach-que

Differential Revision: https://secure.phabricator.com/D15734
This commit is contained in:
epriestley
2016-04-16 08:48:05 -07:00
parent b2d2f03dea
commit 025b243e27
2 changed files with 25 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
$link = trim($matches[1]);
// Handle relative links.
if (substr($link, 0, 2) === './') {
if ((substr($link, 0, 2) === './') || (substr($link, 0, 3) === '../')) {
$base = null;
$context = $this->getEngine()->getConfig('contextObject');
if ($context !== null && $context instanceof PhrictionContent) {
@@ -33,7 +33,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
}
if ($base !== null) {
$base_parts = explode('/', rtrim($base, '/'));
$rel_parts = explode('/', substr(rtrim($link, '/'), 2));
$rel_parts = explode('/', rtrim($link, '/'));
foreach ($rel_parts as $part) {
if ($part === '.') {
// Consume standalone dots in a relative path, and do