You are here

public static function Typogrify::initial_quotes in Typogrify 5

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

initial_quotes

Wraps initial quotes in ``class="dquo"`` for double quotes or ``class="quo"`` for single quotes. Works in these block tags ``(h1-h6, p, li)`` and also accounts for potential opening inline elements ``a, em, strong, span, b, i`` Optionally choose to apply quote span tags to Gullemets as well.

2 calls to Typogrify::initial_quotes()
Typogrify::filter in ./typogrify.class.php
typogrify
_typogrify_process in ./typogrify.module

File

./typogrify.class.php, line 131
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 initial_quotes($text, $do_guillemets = false) {
  $quote_finder = "/((<(p|h[1-6]|li)[^>]*>|^)                     # start with an opening p, h1-6, li or the start of the string\n                    \\s*                                             # optional white space! \n                    (<(a|em|span|strong|i|b)[^>]*>\\s*)*)            # optional opening inline tags, with more optional white space for each.\n                    ((\"|&ldquo;|&\\#8220;)|('|&lsquo;|&\\#8216;))    # Find me a quote! (only need to find the left quotes and the primes)\n                                                                    # double quotes are in group 7, singles in group 8\n                    /ix";
  if ($do_guillemets) {
    $quote_finder = "";
  }
  return preg_replace_callback($quote_finder, array(
    'Typogrify',
    '_quote_wrapper',
  ), $text);
}