Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/markup/blockrule/PhutilRemarkupNoteBlockRule.php
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | public function markupText($text, $children) { | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
$attributes, | $attributes, | ||||
$content); | $content); | ||||
} | } | ||||
private function getRegEx() { | private function getRegEx() { | ||||
static $regex; | |||||
if ($regex === null) { | |||||
$words = array( | $words = array( | ||||
'NOTE', | 'NOTE', | ||||
'IMPORTANT', | 'IMPORTANT', | ||||
'WARNING', | 'WARNING', | ||||
); | ); | ||||
foreach ($words as $k => $word) { | foreach ($words as $k => $word) { | ||||
$words[$k] = preg_quote($word, '/'); | $words[$k] = preg_quote($word, '/'); | ||||
} | } | ||||
$words = implode('|', $words); | $words = implode('|', $words); | ||||
return | $regex = | ||||
'/^(?:'. | '/^(?:'. | ||||
'(?:\((?P<hideword>'.$words.')\))'. | '(?:\((?P<hideword>'.$words.')\))'. | ||||
'|'. | '|'. | ||||
'(?:(?P<showword>'.$words.'):))\s*'. | '(?:(?P<showword>'.$words.'):))\s*'. | ||||
'/'; | '/'; | ||||
} | } | ||||
return $regex; | |||||
} | |||||
} | } |