Created
January 11, 2016 20:03
-
-
Save vorvulev/971fce91880f286740bf to your computer and use it in GitHub Desktop.
Висячая пунктуация PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tiny = array('ни', 'не', 'и', 'но', 'а', 'или', 'да', 'как', | |
'из-за', 'про', 'по', 'за', 'для', 'на', | |
'до', 'при', 'меж', 'о', 'у', 'в', 'во', | |
'с', 'со', 'от', 'ото', 'из', 'без', 'безо', | |
'к', 'ко', 'об', 'обо', 'под', 'подо', | |
'над', 'перед', 'передо'); | |
$text = preg_replace('~(\s)«~', | |
' <span class="hpquote">«</span>', $text); | |
$text = preg_replace('~[^>]«~', '<span class="hpquote">«</span>', $text); | |
$text = preg_replace('~^«~', '<span class="hpquote">«</span>', $text); | |
$text = preg_replace('~(' . | |
implode('|', $tiny) . | |
')\s <span class="hpquote">«</span>~', | |
'\1 «', $text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.hpspace { | |
margin-right: 0.7em; | |
} | |
.hpquote { | |
margin-left: -0.7em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment