Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/markup/blockrule/PhutilRemarkupHorizontalRuleBlockRule.php
12241 views
1
<?php
2
3
final class PhutilRemarkupHorizontalRuleBlockRule
4
extends PhutilRemarkupBlockRule {
5
6
/**
7
* This rule executes at priority `300`, so it can preempt the list block
8
* rule and claim blocks which begin `---`.
9
*/
10
public function getPriority() {
11
return 300;
12
}
13
14
public function getMatchingLineCount(array $lines, $cursor) {
15
$num_lines = 0;
16
$pattern = '/^\s*(?:_{3,}|\*\s?\*\s?\*(\s|\*)*|\-\s?\-\s?\-(\s|\-)*)$/';
17
if (preg_match($pattern, rtrim($lines[$cursor], "\n\r"))) {
18
$num_lines++;
19
$cursor++;
20
while (isset($lines[$cursor]) && !strlen(trim($lines[$cursor]))) {
21
$num_lines++;
22
$cursor++;
23
}
24
}
25
26
return $num_lines;
27
}
28
29
public function markupText($text, $children) {
30
if ($this->getEngine()->isTextMode()) {
31
return rtrim($text);
32
}
33
34
return phutil_tag('hr', array('class' => 'remarkup-hr'));
35
}
36
37
}
38
39