Kirby plugin to remove p tags from around kirby text

Sometimes in your kirby template you want to format text using markdown (or in this case, the kirbytext) function, without the <p> tags.

However, kirby text always outputs the tags. For example, this:

<small><?php echo kirbytext($site->copyright()) ?></small>


<small><p>your copyright text and <a href="#">link</a>.</p></small>

Using the following plugin, this:

<small><?php echo kirbytextSans($site->copyright()) ?></small>


<small>your copyright text and <a href="#">link</a>.</small>

Simply, create a file called kirbytextSans.php and place it in your /site/plugins directory.

Paste in the following code:


 * Add support to remove p tags from around kirby formatted text
 * Author: Rob James
 * License: MIT License
function kirbytextSans($text='') {
    $text = kirbytext::init($text, true);
    return preg_replace('/<p>(.*)<\/p>/', '$1', $text);

And you're go to go.

Simply replace kirbytext references with kirbytextSans in your templates whenever youwant the <p> tags removed.