You are here

protected static function SmartyPants::stupefyEntities in Typogrify 8

StupefyEntities.

Example input: “Hello — world.” Example output: "Hello -- world."

Parameters

string $_: Input text.

Return value

string The string, with each SmartyPants HTML entity translated to it's ASCII counterpart.

1 call to SmartyPants::stupefyEntities()
SmartyPants::process in src/SmartyPants.php
SmartyPants.

File

src/SmartyPants.php, line 1166

Class

SmartyPants
SmartyPants - Smart punctuation for web sites.

Namespace

Drupal\typogrify

Code

protected static function stupefyEntities($_) {

  // Dashes               en-dash    em-dash.
  $_ = str_replace([
    '–',
    '—',
  ], [
    '-',
    '--',
  ], $_);

  // Single quote         open       close.
  $_ = str_replace([
    '‘',
    '’',
    '‚',
  ], "'", $_);

  // Double quote         open       close.
  $_ = str_replace([
    '“',
    '”',
    '„',
  ], '"', $_);

  // Ellipsis.
  $_ = str_replace('…', '...', $_);
  return $_;
}