You are here

function EducateDashesOldSchoolInverted in Typogrify 7

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

EducateDashesOldSchoolInverted.

Parameters

string $_: Input text.

Return value

string The string, with each instance of "--" translated to an em-dash HTML entity, and each "---" translated to an en-dash HTML entity. Two reasons why: First, unlike the en- and em-dash syntax supported by EducateDashesOldSchool(), it's compatible with existing entries written before SmartyPants 1.1, back when "--" was only used for em-dashes. Second, em-dashes are more common than en-dashes, and so it sort of makes sense that the shortcut should be shorter to type. (Thanks to Aaron Swartz for the idea.)

1 call to EducateDashesOldSchoolInverted()
SmartyPants in ./smartypants.php
SmartyPants.
1 string reference to 'EducateDashesOldSchoolInverted'
SmartDashes in ./smartypants.php
SmartDashes.

File

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

Code

function EducateDashesOldSchoolInverted($_) {

  // Dashes               en         em.
  $_ = str_replace(array(
    "---",
    "--",
  ), array(
    '–',
    '—',
  ), $_);
  return $_;
}