HTML Inside Custom KirbyTag

Good Saturday everyone.
I have a question related to html inside custom kirbytags.

I have this custom kirby tag I’m using to format interviews (and an identical one for the answers)

kirbytext::$tags['q'] = array(
    'html' => function($tag) { return "<div class='q'>{$tag->attr('q')}</div>"; }
);

And I’m using it like this

(q: Hello world)

Now, the problem with this code is that the content inside the kirby tag is not wrapped in <p> and bolds and italics are not converted so if I do this…

(q: Hello **world**)

…What I get in the frontend is this

<div class="q">Hello **world**</div>

instead of this

<div class="q"><p>Hello <strong>world</strong></p></div>

Is there a way to solve this?

Have you tried this:

kirbytext::$tags['q'] = array(
    'html' => function($tag) { return "<div class='q'>kirbytext({$tag->attr('q')})</div>"; }
);

?

1 Like

Ok that does not work but this obviously does

'html' => function($tag) { return "<div class='q'>" . kirbytext($tag->attr('q')) . "</div>"; }

Thanks :wink:

1 Like