You are here

public static function Typogrify::_cap_wrapper in Typogrify 7

Same name and namespace in other branches
  1. 5 typogrify.class.php \Typogrify::_cap_wrapper()
  2. 6 typogrify.class.php \Typogrify::_cap_wrapper()

Helper method for caps method - used for preg_replace_callback

File

./typogrify.class.php, line 39
typogrify.class.php Defines a class for providing different typographical tweaks to HTML

Class

Typogrify
@file typogrify.class.php Defines a class for providing different typographical tweaks to HTML

Code

public static function _cap_wrapper($matchobj) {
  if (!empty($matchobj[2])) {
    return sprintf('<span class="caps">%s</span>', $matchobj[2]);
  }
  else {
    $mthree = $matchobj[3];
    if ($mthree[strlen($mthree) - 1] == " ") {
      $caps = substr($mthree, 0, -1);
      $tail = ' ';
    }
    else {
      $caps = $mthree;
      $tail = $matchobj[4];
    }
    return sprintf('<span class="caps">%s</span>%s', $caps, $tail);
  }
}