transform($body, 'Xhtml'); $body = html_entity_decode($body, ENT_COMPAT, 'UTF-8'); $form['body']['#default_value'] = $body; } function textwiki_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { case 'validate': // no break case 'submit': if (strpos($node->body, "<") !== false) { $node->body = _html_to_wiki($node->body); $node->teaser = node_teaser($node->body); } break; } } function _html_to_wiki($text) { $text = stripslashes($text); $text = str_replace("\r", '', $text); $text = str_replace("\\", '', $text); $text = str_replace("\n", ' ', $text); $text = str_replace(" ", ' ', $text); $text = html_entity_decode($text, ENT_COMPAT, 'UTF-8'); // external urls $text = preg_replace('/]*>(.+?)<\/a>/i', "[$1 $2]", $text); // strip attributes $text = preg_replace("/<(\/?)(\w+)([^>\/]*)(\/)?>/eims", "strtolower('<$1$2$4>')", $text); // nested lists are not suported! // ol $text = preg_replace("/
    .*?<\/ol>/eims", "\"\n\". str_replace('
  1. ', \"\n
  2. #\", '$0')", $text); // ul $text = preg_replace("/