Bug in custom kirby tags


I’m not sure wether this is a bug so I decided to post it here instead of opening an issue on GitHub. The following tag (bugtest:) causes all following text not to be renders by kirbytext.


kirbytext::$tags['bugtest'] = array(
    'html' => function($tag) {
        $basecolors = array('a','b','c');
        $output = "<h1>H1</h1>";
        foreach ($basecolors as $b) {
            $output .= $b;
        return $output;


Title: Home


Text: # works

some text


# doesn't work

some text

I.e. the second headline shows on the site as # doesn't work.

This doesn’t happen when …

  • … commenting out / removing the line $output .= $b; in the loop
  • removing the HTML tags from $output = "<h1>H1</h1>";, i.e. $output = "H1";
  • replacing the HTML tags with markdown, i.e. $output = "#H1\n";

… obviously only the last case results in the desired output,