You are here

function unicode_conversion_map in Typogrify 6

Same name and namespace in other branches
  1. 7 unicode-conversion.php \unicode_conversion_map()

Return the unicode conversion maps.

Parameters

string $type: The map type we're looking for, one of 'ligature', 'punctuation', 'arrow' 'nested' or 'all'.

Return value

array Array of conversions, keyed by the original string.

4 calls to unicode_conversion_map()
convert_characters in ./unicode-conversion.php
Perform character conversion.
_typogrify_default_settings in ./typogrify.module
Return the default settings.
_typogrify_process in ./typogrify.module
Processing function to apply the Typogrify filters
_typogrify_settings in ./typogrify.module
Typogrify filter settings form.

File

./unicode-conversion.php, line 12

Code

function unicode_conversion_map($type = 'all') {
  $map = array(
    // See http://www.unicode.org/charts/PDF/UFB00.pdf
    'ligature' => array(
      'ffi' => 'ffi',
      'ffl' => 'ffl',
      'ff' => 'ff',
      'fi' => 'fi',
      'fl' => 'fl',
      'ij' => 'ij',
      'IJ' => 'IJ',
      'st' => 'st',
      'ss' => 'ß',
    ),
    // See http:#www.unicode.org/charts/PDF/U2000.pdf
    'punctuation' => array(
      '...' => '…',
      '..' => '‥',
      '. . .' => '…',
      '---' => '—',
      '--' => '–',
    ),
    // See http:#www.unicode.org/charts/PDF/U2190.pdf
    'arrow' => array(
      '->>' => '↠',
      '<<-' => '&#x219e;',
      '->|' => '&#x21e5;',
      '|<-' => '&#x21e4;',
      '<->' => '&#x2194;',
      '->' => '&#x2192;',
      '<-' => '&#x2190;',
      '<=>' => '&#x21d4;',
      '=>' => '&#x21d2;',
      '<=' => '&#x21d0;',
    ),
  );
  if ($type == 'all') {
    return array_merge($map['ligature'], $map['arrow'], $map['punctuation']);
  }
  elseif ($type == 'nested') {
    return $map;
  }
  else {
    return $map[$type];
  }
}