Custom content in kirbytext

Try this:

<?php

kirbytext::$pre[] = function($kirbytext, $text) {
  $text = preg_replace_callback('!\(centertext(…|\.{3})\)(.*?)\((…|\.{3})centertext\)!is', function($matches) use($kirbytext) {
    $customtext = $matches[2];
    $html    = "";
    $field = new Field($kirbytext->field->page, null, trim($customtext));
    $html = '<div class="center">' . $field->kt() . '</div>';
    return $html;
  }, $text);
  return $text;
};