# Kirbytext/markdown without p-Element

**URL:** <https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 13, 2015, 3:35pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438 "2015-03-13T15:35:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobiasfabian](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasfabian/32/13470_2.png) [@tobiasfabian](https://forum.getkirby.com/u/tobiasfabian)\
**Post date:** [March 13, 2015, 3:35pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438/1 "2015-03-13T15:35:12Z")

</div>

I have something like this:

```auto
<span><?=$page->text()->kirbytext()?></span>

```

which of cause renders into something this:

```auto
<span><p>Lorem <a href="#">Ispum</a></p></span>

```

but I want something like this (without the p-Element)

```auto
<span>Lorem <a href="#">Ispum</a></span>

```

I tried to create a new [field method](http://getkirby.com/docs/advanced/field-methods), which would be fine. But I don’t know how to convert `(link: # text: Lorem)` to `<a href="#">Lorem</a>`.

Any smart ideas for this?

---

<div class="post-metadata">

**Author:** ![Luke](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/luke/32/3083_2.png) [@Luke](https://forum.getkirby.com/u/Luke)\
**Post date:** [March 13, 2015, 3:38pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438/2 "2015-03-13T15:38:45Z")

</div>

You could try checking out [this page](http://www.creativeblob.com/blog/remove-p-tags-from-kirby-text). I haven’t tested it though.

---

<div class="post-metadata">

**Author:** ![tobiasfabian](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/tobiasfabian/32/13470_2.png) [@tobiasfabian](https://forum.getkirby.com/u/tobiasfabian)\
**Post date:** [March 13, 2015, 4:01pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438/3 "2015-03-13T16:01:12Z")

</div>

That’s exactly what I’ve been looking for.

I just had to make a small adjustment.  
This line throws an error (`Call to undefined method Kirbytext::init()`)

```auto
$text = kirbytext::init($text, true);

```

but

```auto
$text = kirbytext($text);

```

works all fine.

Thanks @Luke.

---

<div class="post-metadata">

**Author:** ![jbeyerstedt](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jbeyerstedt/32/3976_2.png) [@jbeyerstedt](https://forum.getkirby.com/u/jbeyerstedt)\
**Post date:** [March 16, 2015, 9:43pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438/4 "2015-03-16T21:43:30Z")

</div>

I had this problem too. Sometimes it is necessary to control the surrounding `<p>` tags by your own, but keep that the kirbytext is pared as it used to be.  
I had also used kirbytestSans.php at first, but there were some Problems with kirby 2, so I changed some things and made a separate git repository:

> **[jbeyerstedt/kirby-plugin-kirbytextRaw](https://github.com/jbeyerstedt/kirby-plugin-kirbytextRaw)**
>
> Kirby Plugin to get kirbytext() without the enclosing -tags (obsolete for kirby 3) - jbeyerstedt/kirby-plugin-kirbytextRaw

The big problem for me was, that kirbytextSans has complications if there are several paragraphs in the text, so my plugin does only remove the first opening and last closing paragraph tag.

---

<div class="post-metadata">

**Author:** ![ezraverheijen](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ezraverheijen/32/2955_2.png) [@ezraverheijen](https://forum.getkirby.com/u/ezraverheijen)\
**Post date:** [November 30, 2016, 4:06pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438/5 "2016-11-30T16:06:16Z")

</div>

Don’t like to bump topics, but I think this can be useful.  
We only want to remove the first and last p tag from kirbytext, right? I always use a custom field method for this:

```
field::$methods['kirbytextSans'] = function($field) {
  return str::substr(kirbytext($field->value), 3, -4);
};

```

No regex! 😜

---

<div class="post-metadata">

**Author:** ![thewebprojects](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/thewebprojects/32/10107_2.png) [@thewebprojects](https://forum.getkirby.com/u/thewebprojects)\
**Post date:** [March 31, 2019, 6:46pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438/6 "2019-03-31T18:46:19Z")

</div>

Since Kirby v3.1.0 you can use `$field->kirbytextinline()`. More on that [here](https://getkirby.com/docs/reference/templates/field-methods/kirbytextinline).

---

<div class="post-metadata">

**Author:** ![distantnative](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/distantnative/32/11319_2.png) [@distantnative](https://forum.getkirby.com/u/distantnative)\
**Post date:** [February 6, 2025, 5:23pm UTC](https://forum.getkirby.com/t/kirbytext-markdown-without-p-element/438/7 "2025-02-06T17:23:16Z")

</div>

Archived on February 6, 2025, 5:23pm UTC


