Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/markup/blockrule/PhutilRemarkupDefaultBlockRule.php
12241 views
1
<?php
2
3
final class PhutilRemarkupDefaultBlockRule extends PhutilRemarkupBlockRule {
4
5
public function getPriority() {
6
return 750;
7
}
8
9
public function getMatchingLineCount(array $lines, $cursor) {
10
return 1;
11
}
12
13
public function markupText($text, $children) {
14
$engine = $this->getEngine();
15
16
$text = trim($text);
17
$text = $this->applyRules($text);
18
19
if ($engine->isTextMode()) {
20
if (!$this->getEngine()->getConfig('preserve-linebreaks')) {
21
$text = preg_replace('/ *\n */', ' ', $text);
22
}
23
return $text;
24
}
25
26
if ($engine->getConfig('preserve-linebreaks')) {
27
$text = phutil_escape_html_newlines($text);
28
}
29
30
if (!strlen($text)) {
31
return null;
32
}
33
34
$default_attributes = $engine->getConfig('default.p.attributes');
35
if ($default_attributes) {
36
$attributes = $default_attributes;
37
} else {
38
$attributes = array();
39
}
40
41
return phutil_tag('p', $attributes, $text);
42
}
43
44
}
45
46