You are here

function StupefyEntities in Typogrify 5

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

File

./smartypants.php, line 592

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 $_;
}