mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-10 14:51:06 +01:00
make remarkup savvier about fragments in phriction links
Summary: use PhutilURI class to get the slug and the fragment, normalize the slug, and then glue it back together with another PhutilURI fixes https://github.com/facebook/phabricator/issues/228 Test Plan: had a few links like [[ example/doc#title | wiki fun ]] and verified links generated were correct Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3894
This commit is contained in:
parent
c6503f019f
commit
5b1d73e5dd
1 changed files with 9 additions and 5 deletions
|
@ -15,19 +15,23 @@ final class PhabricatorRemarkupRulePhriction
|
|||
|
||||
public function markupDocumentLink($matches) {
|
||||
|
||||
$slug = trim($matches[1]);
|
||||
$name = trim(idx($matches, 2, $slug));
|
||||
$link = trim($matches[1]);
|
||||
$name = trim(idx($matches, 2, $link));
|
||||
$name = explode('/', trim($name, '/'));
|
||||
$name = end($name);
|
||||
|
||||
$slug = PhabricatorSlug::normalize($slug);
|
||||
$uri = PhrictionDocument::getSlugURI($slug);
|
||||
$uri = new PhutilURI($link);
|
||||
$slug = $uri->getPath();
|
||||
$fragment = $uri->getFragment();
|
||||
$slug = PhabricatorSlug::normalize($slug);
|
||||
$slug = PhrictionDocument::getSlugURI($slug);
|
||||
$href = (string) id(new PhutilURI($slug))->setFragment($fragment);
|
||||
|
||||
return $this->getEngine()->storeText(
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $uri,
|
||||
'href' => $href,
|
||||
'class' => 'phriction-link',
|
||||
),
|
||||
phutil_escape_html($name)));
|
||||
|
|
Loading…
Reference in a new issue