You are here

public static function Typogrify::dash in Typogrify 8

Puts a   before and after an &ndash or —.

Dashes may have whitespace or an `` `` on both sides.

Parameters

string $text: The text to work on.

Return value

string The modified text.

2 calls to Typogrify::dash()
Typogrify::filter in src/TwigExtension/Typogrify.php
Filter text by Typogrify.
Typogrify::filter in src/Typogrify.php
Typogrify.

File

src/Typogrify.php, line 42

Class

Typogrify
Class \Drupal\typogrify\Typogrify.

Namespace

Drupal\typogrify

Code

public static function dash($text) {
  $dash_finder = "/(\\s| | )*(—|–|–|–|—|—)(\\s| | )*/";
  return preg_replace($dash_finder, ' \\2 ', $text);
}