Differential D21821 Diff 52001 src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/markup/markuprule/PhutilRemarkupDocumentLinkRule.php
Show All 40 Lines | public function apply($text) { | ||||
return $text; | return $text; | ||||
} | } | ||||
protected function renderHyperlink($link, $name) { | protected function renderHyperlink($link, $name) { | ||||
$engine = $this->getEngine(); | $engine = $this->getEngine(); | ||||
$is_anchor = false; | $is_anchor = false; | ||||
if (strncmp($link, '/', 1) == 0) { | if (strncmp($link, '/', 1) == 0) { | ||||
$base = $engine->getConfig('uri.base'); | $base = phutil_string_cast($engine->getConfig('uri.base')); | ||||
$base = rtrim($base, '/'); | $base = rtrim($base, '/'); | ||||
$link = $base.$link; | $link = $base.$link; | ||||
} else if (strncmp($link, '#', 1) == 0) { | } else if (strncmp($link, '#', 1) == 0) { | ||||
$here = $engine->getConfig('uri.here'); | $here = $engine->getConfig('uri.here'); | ||||
$link = $here.$link; | $link = $here.$link; | ||||
$is_anchor = true; | $is_anchor = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | return $this->markupDocumentLink( | ||||
$matches[0], | $matches[0], | ||||
$matches[2], | $matches[2], | ||||
$matches[1], | $matches[1], | ||||
)); | )); | ||||
} | } | ||||
public function markupDocumentLink(array $matches) { | public function markupDocumentLink(array $matches) { | ||||
$uri = trim($matches[1]); | $uri = trim($matches[1]); | ||||
$name = trim(idx($matches, 2)); | $name = trim(idx($matches, 2, '')); | ||||
if (!$this->isFlatText($uri)) { | if (!$this->isFlatText($uri)) { | ||||
return $matches[0]; | return $matches[0]; | ||||
} | } | ||||
if (!$this->isFlatText($name)) { | if (!$this->isFlatText($name)) { | ||||
return $matches[0]; | return $matches[0]; | ||||
} | } | ||||
Show All 38 Lines |