Skip to content

Instantly share code, notes, and snippets.

@handlename
Created September 22, 2010 12:23
Show Gist options
  • Save handlename/591572 to your computer and use it in GitHub Desktop.
Save handlename/591572 to your computer and use it in GitHub Desktop.
#!/usr/bin/php
<?php
$text = file_get_contents('php://stdin');
$text = preg_replace('/<\/?div[^>]*\/?>/', '', $text);
$text = preg_replace('/<\/?a[^>]*>/', '', $text);
$text = preg_replace('/<span[^\/]+\/span>/', '', $text);
$text = preg_replace('/ id="[^"]*"/', '', $text);
$text = preg_replace('/ class="[^"]*"/', '', $text);
$text = preg_replace('/<b>/', '<em>', $text);
$text = preg_replace('/<\/b>/', '</em>', $text);
$text = preg_replace('/<i>/', '<strong>', $text);
$text = preg_replace('/<\/i>/', '</strong>', $text);
$text = preg_replace('/\n\n+/', PHP_EOL.PHP_EOL, $text);
echo $text;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment