Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function texyToText(\Texy $texy)
- {
- $html = $texy->getDOM()->toHtml($texy);
- $s = TexyUtf::utf2html($html, $texy->encoding);
- // remove tags
- $s = preg_replace('#<(script|style)(.*)</\\1>#Uis', '', $s);
- $s = str_replace('#><#', '> <', $s); // supply spaces
- $s = strip_tags($s);
- $s = preg_replace('#\n\s*\n\s*\n[\n\s]*\n#', "\n\n", $s);
- $s = preg_replace('#\s\s+#', " ", $s);
- // entities -> chars
- $s = self::unescapeHtml($s);
- // convert nbsp to normal space and remove shy
- $s = strtr($s, array(
- "\xC2\xAD" => '', // shy
- "\xC2\xA0" => ' ', // nbsp
- ));
- return $s;
- }
Advertisement
Add Comment
Please, Sign In to add comment