Way to Use Parenthesis inside Kirbytag?

It’s a bit hacky, but you can use a post filter to replace other characters with parenthesis, for example square brackets which are safe to use within Kirbytags but almost never needed in normal website content. Here’s the code for it (add to plugins folder as php file) :

<?php
kirbytext::$post[] = function($kirbytext, $value) {
  $snippets = array(
    '[' => '(',
    ']' => ')',
  );
  $keys     = array_keys($snippets);
  $values   = array_values($snippets);
  return str_replace($keys, $values, $value);
};

This will turn (tel: [012] 345678) into (012) 345678.

1 Like