public static function Typogrify::amp in Typogrify 8
Enable custom styling of ampersands.
Wraps apersands in html with '<span class="amp">', so they can be styled with CSS. Ampersands are also normalized to '&. Requires ampersands to have whitespace or an ' ' on both sides.
It won't mess up & that are already wrapped, in entities or URLs.
Parameters
string $text: The text to work on.
Return value
string The modified text.
4 calls to Typogrify::amp()
- SmartyPants::smartAmpersand in src/
SmartyPants.php - Wrapping ampersands.
- Typogrify::filter in src/
TwigExtension/ Typogrify.php - Filter text by Typogrify.
- Typogrify::filter in src/
Typogrify.php - Typogrify.
- TypogrifyClassTest::testAmpersandWrapping in tests/
src/ Unit/ TypogrifyClassTest.php - Tests ampersand-wrapping.
File
- src/
Typogrify.php, line 25
Class
Namespace
Drupal\typogrifyCode
public static function amp($text) {
$amp_finder = "/(\\s| )(&|&|&\\#38;|&)(\\s| )/";
return preg_replace($amp_finder, '\\1<span class="amp">&</span>\\3', $text);
}