public generateGuideUrl ( string $file ) : string | ||
$file | string | |
리턴 | string |
public function generateGuideUrl($file)
{
//skip parsing external url
if (strpos($file, 'https://') !== false || strpos($file, 'http://') !== false) {
return $file;
}
$hash = '';
if (($pos = strpos($file, '#')) !== false) {
$hash = substr($file, $pos);
$file = substr($file, 0, $pos);
}
return rtrim($this->guideUrl, '/') . '/' . $this->guidePrefix . basename($file, '.md') . '.html' . $hash;
}
/** * @inheritdoc */ protected function parseLink($markdown) { list($result, $skip) = parent::parseLink($markdown); // add special syntax for linking to the guide $result = preg_replace_callback('/href="guide:([A-z0-9-.#]+)"/i', function ($match) { return 'href="' . static::$renderer->generateGuideUrl($match[1]) . '"'; }, $result, 1); return [$result, $skip]; }