Porting Wordpress wpautop Function