You are here

function StupefyEntities in Typogrify 6

Same name and namespace in other branches
  1. 5 smartypants.php \StupefyEntities()
  2. 7 smartypants.php \StupefyEntities()
1 call to StupefyEntities()
SmartyPants in ./smartypants.php

File

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

Code

function StupefyEntities($_) {

  #

  #   Parameter:  String.

  #   Returns:    The string, with each SmartyPants HTML entity translated to

  #               its ASCII counterpart.

  #

  #   Example input:  “Hello — world.”

  #   Example output: "Hello -- world."

  #

  #  en-dash    em-dash
  $_ = str_replace(array(
    '–',
    '—',
  ), array(
    '-',
    '--',
  ), $_);

  # single quote         open       close
  $_ = str_replace(array(
    '‘',
    '’',
  ), "'", $_);

  # double quote         open       close
  $_ = str_replace(array(
    '“',
    '”',
  ), '"', $_);
  $_ = str_replace('…', '...', $_);

  # ellipsis
  return $_;
}