Escape Kirbytag Parenthesis

I am pretty sure about this topic was spoken before but I could only find threads about escaping parenthesis inside kirbytags. But I want the whole kirbytag to be escaped inside a <code> element and I just don’t get it to work…

Just like: (link: text:Google)


1 Like

The website does it like this:



And then a str_replace in the template:

<?php echo str_replace('(\\', '(', kirbytext($page->text())) ?>



Nice, that does the trick :wink:

But why doesn’t this work in a kirbytext post-filter? If I use the code below it just removes the kirbytag completely from the DOM.

kirbytext::$post[] = function($kirbytext, $value) {
    return str_replace('(\\','(', $value);

Good question, I would have expected a filter to work as well. Will get back to this later (after cooking and eating :shallow_pan_of_food:).

1 Like

Hm, I tested this and the filter works for me as expected (tested with Kirby 2.5.4) :thinking:

I realized that it just doesn’t work within the columns-plugin by @bastianallgeier (columns.php). But I am definitely not enough of a regex-wizard to figure out why :rofl:

I assume this is not because of the regex pattern but rather because the kirbytext() method is called on the field within the pre filter (so that the post filter does not have any effect).

Sounds reasonable. I think I’ll stay with your original answer as it works seamlessly.