# Problems with paragraph on kirbytag

**URL:** <https://forum.getkirby.com/t/problems-with-paragraph-on-kirbytag/25523>\
**Category:** Questions\
**Tags:** v3\
**Created:** [May 17, 2022, 10:43pm UTC](https://forum.getkirby.com/t/problems-with-paragraph-on-kirbytag/25523 "2022-05-17T22:43:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanStieler](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/janstieler/32/15642_2.png) [@JanStieler](https://forum.getkirby.com/u/JanStieler)\
**Post date:** [May 17, 2022, 10:43pm UTC](https://forum.getkirby.com/t/problems-with-paragraph-on-kirbytag/25523/1 "2022-05-17T22:43:55Z")

</div>

Hi,  
I have a problem with a own Kirbytag for centering text.  
The tags will be replaced but paragraphs will be mixed between.  
Here is the code:

```auto
<?php
Kirby::plugin('kdjfs/centertxt', [
    'options' => [
        'class' => 'center-text'
    ],
    'hooks' => [
        'kirbytags:before' => function ($text, array $data = []) {

            $text = preg_replace_callback('!\(center(…|\.{3})\)(.*?)\((…|\.{3})center\)!is', function ($matches) use ($text) {
                $html = kirbytext($matches[2]);
                return '<span class="' . option('kdjfs.centertxt.class') . '">' . $html . '</span>';
            }, $text);

            return $text;
        }
    ]
]);

```

and the markdown will look like `(center…)Lorem Ipsum(…)`.  
The Output should `<p><span class="center-text">Lorem Ipsum</span></p>`.  
But the Output is

```auto
<p>
<span class="center-text"></span>
</p>
<p>
Lorem Ipsum
</p>

```

I thing have an problem with parcing flow problems. Because if I dump inside the plugin the output will be okay.

Disable the paragraphs is not so smart to solve the problem.  
Hopefull someone had an idea.

---

<div class="post-metadata">

**Author:** ![rasteiner](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/rasteiner/32/4788_2.png) [@rasteiner](https://forum.getkirby.com/u/rasteiner)\
**Post date:** [May 18, 2022, 1:05pm UTC](https://forum.getkirby.com/t/problems-with-paragraph-on-kirbytag/25523/2 "2022-05-18T13:05:16Z")

</div>

> [@JanStieler](#):
>
> and the markdown will look like `(center…)Lorem Ipsum(…)` .

ehm, according to your regex, it should be `(center…)Lorem Ipsum(…center)`.

aside from this, you probably want to use `kirbytextinline()` instead of `kirbytext()`
