From f72220850e92f76eab4e7a2b0c7e00ec372ae050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 18 Jan 2018 16:50:30 +0100 Subject: [PATCH 1/2] feat: render new lines as
in LongText --- types/LongText.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/types/LongText.php b/types/LongText.php index 5188c232..2facff99 100644 --- a/types/LongText.php +++ b/types/LongText.php @@ -24,7 +24,12 @@ class LongText extends AbstractMultiBaseType { * @return bool true if $mode could be satisfied */ public function renderValue($value, \Doku_Renderer $R, $mode) { - $R->cdata($this->config['prefix'] . $value . $this->config['postfix']); + if ($mode === 'xhtml') { + $valueWithBR = str_replace("\n", '
', hsc($value)); + $R->doc .= hsc($this->config['prefix']) . $valueWithBR . hsc($this->config['postfix']); + } else { + $R->cdata($this->config['prefix'] . $value . $this->config['postfix']); + } return true; } @@ -39,7 +44,7 @@ public function validate($rawvalue) { $rawvalue = cleanText($rawvalue); return $rawvalue; } - + /** * Use a text area for input * From e79e41afc3a8b769d9820a6ef90a209cac0a8db7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= Date: Thu, 18 Jan 2018 17:02:59 +0100 Subject: [PATCH 2/2] fix: use built-in function nl2br --- types/LongText.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/LongText.php b/types/LongText.php index 2facff99..4ffc6113 100644 --- a/types/LongText.php +++ b/types/LongText.php @@ -25,7 +25,7 @@ class LongText extends AbstractMultiBaseType { */ public function renderValue($value, \Doku_Renderer $R, $mode) { if ($mode === 'xhtml') { - $valueWithBR = str_replace("\n", '
', hsc($value)); + $valueWithBR = nl2br(hsc($value)); $R->doc .= hsc($this->config['prefix']) . $valueWithBR . hsc($this->config['postfix']); } else { $R->cdata($this->config['prefix'] . $value . $this->config['postfix']);