function chistka() {
var s = document.getElementById('k1');
var result = s.value.replace(/(>)\s(<)/gmi, '$1\n$2');
s.value = result;
}
include('simple_html_dom.php');
$html = new simple_html_dom();
$html = str_get_html($k1);
$style = $html->find('style',0);
echo $style->outertext;
$body = $html->find('body',0);
echo $body->innertext;