From 8d54c3a0f0c0c23f23c2aef54af57f72407921bd Mon Sep 17 00:00:00 2001
From: Christoph Burschka <christoph@burschka.de>
Date: Sun, 13 Dec 2015 11:43:57 +0100
Subject: [PATCH] Issue #2634160: Append text after last element.

After the last tag is closed, the final bit of text must
be appended to the output.
---
 src/Plugin/Filter/XBBCodeFilter.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/Plugin/Filter/XBBCodeFilter.php b/src/Plugin/Filter/XBBCodeFilter.php
index c67dc5c..42eebf7 100644
--- a/src/Plugin/Filter/XBBCodeFilter.php
+++ b/src/Plugin/Filter/XBBCodeFilter.php
@@ -323,7 +323,10 @@ class XBBCodeFilter extends FilterBase {
         array_push($stack, $tag);
       }
     }
-    return end($stack);
+
+    $root = array_pop($stack);
+    $root->append(substr($text, $root->index));
+    return $root;
   }
 
 }
-- 
1.9.1

