Skip to content

Instantly share code, notes, and snippets.

@vorvulev
Created January 11, 2016 20:03
Show Gist options
  • Save vorvulev/971fce91880f286740bf to your computer and use it in GitHub Desktop.
Save vorvulev/971fce91880f286740bf to your computer and use it in GitHub Desktop.
Висячая пунктуация PHP
$tiny = array('ни', 'не', 'и', 'но', 'а', 'или', 'да', 'как',
'из-за', 'про', 'по', 'за', 'для', 'на',
'до', 'при', 'меж', 'о', 'у', 'в', 'во',
'с', 'со', 'от', 'ото', 'из', 'без', 'безо',
'к', 'ко', 'об', 'обо', 'под', 'подо',
'над', 'перед', 'передо');
$text = preg_replace('~(\s)«~',
' <span class="hpquote">«</span>', $text);
$text = preg_replace('~[^&gt;]«~', '<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);
.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