mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 04:50:55 +01:00
Fix parsing of anchors in Phriction document link syntax
Summary: Ref T4280. At some point (probably D15732) we started getting anchor parsing wrong. Just pop the anchor off before doing all the logic, then put it back on at the end. Test Plan: Tested various forms like: ``` [[ x ]] [[ x | z ]] [[ x#y | z ]] [[ ./x#y | z ]] ``` Reviewers: chad Reviewed By: chad Maniphest Tasks: T4280 Differential Revision: https://secure.phabricator.com/D16083
This commit is contained in:
parent
78fab485b4
commit
72d554aa9b
2 changed files with 18 additions and 8 deletions
|
@ -16,7 +16,15 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function markupDocumentLink(array $matches) {
|
public function markupDocumentLink(array $matches) {
|
||||||
$link = trim($matches[1]);
|
// If the link contains an anchor, separate that off first.
|
||||||
|
$parts = explode('#', trim($matches[1]), 2);
|
||||||
|
if (count($parts) == 2) {
|
||||||
|
$link = $parts[0];
|
||||||
|
$anchor = $parts[1];
|
||||||
|
} else {
|
||||||
|
$link = $parts[0];
|
||||||
|
$anchor = null;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle relative links.
|
// Handle relative links.
|
||||||
if ((substr($link, 0, 2) === './') || (substr($link, 0, 3) === '../')) {
|
if ((substr($link, 0, 2) === './') || (substr($link, 0, 3) === '../')) {
|
||||||
|
@ -67,6 +75,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
|
||||||
$metadata[] = array(
|
$metadata[] = array(
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'link' => $link,
|
'link' => $link,
|
||||||
|
'anchor' => $anchor,
|
||||||
'explicitName' => $name,
|
'explicitName' => $name,
|
||||||
);
|
);
|
||||||
$engine->setTextMetadata(self::KEY_RULE_PHRICTION_LINK, $metadata);
|
$engine->setTextMetadata(self::KEY_RULE_PHRICTION_LINK, $metadata);
|
||||||
|
@ -142,10 +151,11 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule {
|
||||||
|
|
||||||
$uri = new PhutilURI($link);
|
$uri = new PhutilURI($link);
|
||||||
$slug = $uri->getPath();
|
$slug = $uri->getPath();
|
||||||
$fragment = $uri->getFragment();
|
|
||||||
$slug = PhabricatorSlug::normalize($slug);
|
$slug = PhabricatorSlug::normalize($slug);
|
||||||
$slug = PhrictionDocument::getSlugURI($slug);
|
$slug = PhrictionDocument::getSlugURI($slug);
|
||||||
$href = (string)id(new PhutilURI($slug))->setFragment($fragment);
|
|
||||||
|
$anchor = idx($spec, 'anchor');
|
||||||
|
$href = (string)id(new PhutilURI($slug))->setFragment($anchor);
|
||||||
|
|
||||||
$text_mode = $this->getEngine()->isTextMode();
|
$text_mode = $this->getEngine()->isTextMode();
|
||||||
$mail_mode = $this->getEngine()->isHTMLMailMode();
|
$mail_mode = $this->getEngine()->isHTMLMailMode();
|
||||||
|
|
|
@ -42,7 +42,7 @@ final class PhabricatorMarkupEngine extends Phobject {
|
||||||
private $objects = array();
|
private $objects = array();
|
||||||
private $viewer;
|
private $viewer;
|
||||||
private $contextObject;
|
private $contextObject;
|
||||||
private $version = 15;
|
private $version = 16;
|
||||||
private $engineCaches = array();
|
private $engineCaches = array();
|
||||||
private $auxiliaryConfig = array();
|
private $auxiliaryConfig = array();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue