Skip to content

Commit f722208

Browse files
committed
feat: render new lines as <br> in LongText
1 parent f38cc29 commit f722208

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

types/LongText.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ class LongText extends AbstractMultiBaseType {
2424
* @return bool true if $mode could be satisfied
2525
*/
2626
public function renderValue($value, \Doku_Renderer $R, $mode) {
27-
$R->cdata($this->config['prefix'] . $value . $this->config['postfix']);
27+
if ($mode === 'xhtml') {
28+
$valueWithBR = str_replace("\n", '<br>', hsc($value));
29+
$R->doc .= hsc($this->config['prefix']) . $valueWithBR . hsc($this->config['postfix']);
30+
} else {
31+
$R->cdata($this->config['prefix'] . $value . $this->config['postfix']);
32+
}
2833
return true;
2934
}
3035

@@ -39,7 +44,7 @@ public function validate($rawvalue) {
3944
$rawvalue = cleanText($rawvalue);
4045
return $rawvalue;
4146
}
42-
47+
4348
/**
4449
* Use a text area for input
4550
*

0 commit comments

Comments
 (0)