You are here

function SmartEllipses in Typogrify 7

Same name and namespace in other branches
  1. 5 smartypants.php \SmartEllipses()
  2. 6 smartypants.php \SmartEllipses()

SmartEllipses.

Parameters

string $text: Text to be parsed.

string $attr: Value of the smart_quotes="" attribute.

string $ctx: MT context object (unused).

Return value

string $text with replacements.

File

./smartypants.php, line 486
SmartyPants - Smart punctuation for web sites

Code

function SmartEllipses($text, $attr = NULL, $ctx = NULL) {
  if ($attr == NULL) {
    global $_typogrify_smartypants_attr;
    $attr = $_typogrify_smartypants_attr;
  }
  if ($attr == 0) {

    // Do nothing;
    return $text;
  }
  $tokens;
  $tokens = _TokenizeHTML($text);
  $result = '';

  // Keep track of when we're inside <pre> or <code> tags.
  $in_pre = 0;
  foreach ($tokens as $cur_token) {
    if ($cur_token[0] == "tag") {

      // Don't mess with quotes inside tags.
      $result .= $cur_token[1];
      if (preg_match(SMARTYPANTS_TAGS_TO_SKIP, $cur_token[1], $matches)) {
        $in_pre = isset($matches[1]) && $matches[1] == '/' ? 0 : 1;
      }
    }
    else {
      $t = $cur_token[1];
      if (!$in_pre) {
        $t = ProcessEscapes($t);
        $t = EducateEllipses($t);
      }
      $result .= $t;
    }
  }
  return $result;
}