Kirbytext wraps everything in `<p>`

The Kirbytext method wraps everything in <p> tags. I want to get rid of the

tags but if I tried ktRaw of html it not used my enters form my field in the text.

Does anybody know how to fix this?


There is a kirbytextInline() method, but that only makes sense for single line text, not for multiline text from a textarea field.

What is your use case? Please be more specific what your problem is.

I have two sentences with an enter in between. I can split it into 2 fields but that’s a bit cumbersome.

What is your expected result? And if you don’t want the p-tags, why do you put an “enter” in between? That is standard markdown behaviour.

1 Like

I know it is the standard markdown behaviour but I want to make use of the enters in my panel field but not the p tags. With ktRaw and html I looses the enters from my field.

Do I have to do inline styling?


Oh! I think if I add an class to my code:

<?php echo $page->headlinequote()->kirbytext() ?>

Edit: yes that works out! Thanks @texnixe

I converted the K2 kirbytextraw plugin for Kirby 3:

 * kirby 3 plugin - kirbytextRaw
 * parse text as kirbytext but remove the p tags
 * copyright: Jannik Beyerstedt | |
 * license: GPLv3 License
 * v1.0.1 (27.11.2014)
 * Sample Usage:
 * <?php echo $page->text()->kirbytextraw() ?>

function kirbytextRaw($content) {
  $text = kirbytext($content);
  return preg_replace('/(.*)<\/p>/', '$1', preg_replace('/<p>(.*)/', '$1', $text));

Kirby::plugin('bvdputte/kirbytextraw', [
    'fieldMethods' => [
        'kirbytextraw' => function($field) {
          return kirbytextRaw($field->value);
1 Like

Thank you! appreciate it :slight_smile:

@bvdputte I copied your code and followed the plugin documentation ( but don’t get it working.

I have copied this code and made index.php inside a plugin folder named kirbytextraw. Do I have to do something else?


You have to also call $page->fieldname()->kirbytextraw() instead of $page->fieldname()->kirbytext().

Or do you actually get an error message?

Oh shame on me. I made a typo! :sweat_smile: