diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index c8862eece381d9a5686a8882b4b505038449d3d3..c5a8b8218f14a451bfc1f25468a49ab3cc8ef5ca 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -442,6 +442,13 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
             $this->doc .= '</a></dt>'.DOKU_LF.'<dd>';
         }
 
+        if ($text{0} == "\n") {
+            $text = substr($text, 1);
+        }
+        if (substr($text, -1) == "\n") {
+            $text = substr($text, 0, -1);
+        }
+
         if ( is_null($language) ) {
             $this->doc .= '<pre class="'.$type.'">'.$this->_xmlEntities($text).'</pre>'.DOKU_LF;
         } else {