perl -pe 'chomp; $s=!$s,next if s/^\s*<\/?pre>\s*$//i; $_="

$_

" if $s; $_.="\n";' out