Page MenuHomePhabricator
Paste P1209

PhabricatorRemarkupGhcTracRule.php
ActivePublic

Authored by epriestley on Jul 22 2014, 4:25 PM.
Tags
None
Referenced Files
F179900: PhabricatorRemarkupGhcTracRule.php
Jul 22 2014, 4:25 PM
Subscribers
None
<?php
/**
* Looks for references to GHC Trac issues and links to them as a Remarkup rule.
*/
final class PhabricatorRemarkupGhcTracRule
extends PhabricatorRemarkupCustomInlineRule {
public function getPriority() {
return 200.0;
}
public function apply($text) {
return preg_replace_callback(
'/\B#(\d+)/',
array($this, 'markupInlineTracLink'),
$text);
}
public function markupInlineTracLink(array $matches) {
// Change this to your Trac install.
$uri = 'http://your.trac.install.com/whatever/'.$matches[1];
$link = phutil_tag(
'a',
array(
'href' => $uri,
'style' => 'font-weight: bold;',
),
'Trac #'.$matches[1]);
$engine = $this->getEngine();
return $engine->storeText($link);
}
}
// Local Variables:
// fill-column: 80
// indent-tabs-mode: nil
// c-basic-offset: 2
// buffer-file-coding-system: utf-8-unix
// End:

Event Timeline

epriestley changed the title of this paste from untitled to PhabricatorRemarkupGhcTracRule.php.
epriestley updated the paste's language from autodetect to autodetect.