'tr', 'tr' => array('td', 'th'), 'td' => array('ul', 'ol'), 'th' => array('ul', 'ol'), 'ul' => array('ul', 'ol', 'li'), 'ol' => array('ul', 'ol', 'li'), 'div' => array('p', 'table', 'ul', 'ol', 'h2', 'h3', 'h4', 'h5'), 'p' => array('ul', 'ol') ); public $cording_open_tags = array(); public $cording_now_tag; public $cording_mode; public $cording_list_array; public $cording_last_list_level; public $cording_last_list_type; function cording_tag_close_check($tag){ global $_debug; $result = FALSE; if (count($this->cording_open_tags) > 0){ if (is_array($this->enable_nesting_tags[$this->cording_open_tags[0]])){ if (!in_array($tag, $this->enable_nesting_tags[$this->cording_open_tags[0]])){ $result = TRUE; } }else if ($tag != $this->enable_nesting_tags[$this->cording_open_tags[0]]){ $result = TRUE; } } return $result; } function cording_tag_close($tag, $unshift_flug=TRUE, $reset_list_level=TRUE){ if ($this->cording_tag_close_check($tag)){ while($this->cording_tag_close_check($tag)){ $close_tag = array_shift($this->cording_open_tags); echo '\n"; } } if ($unshift_flug){ array_unshift($this->cording_open_tags, $tag); } if ($reset_list_level){ $this->cording_last_list_level = 0; } } function cording_list($new_level, $type, $body){ if (!in_array("p", $this->cording_open_tags)){ $this->cording_tag_close("p", TRUE, TRUE); echo "

\n"; } if ($new_level > $this->cording_last_list_level){ $this->cording_tag_close($type, TRUE, FALSE); $str = '<'.$type.' class=level'.$new_level.'">'."\n".'

  • '.$this->cording_text($body)."
  • \n"; }else if ($new_level < $this->cording_last_list_level){ $str = '<'.$this->cording_last_list_type.">\n".'
  • '.$this->cording_text($body)."
  • \n"; }else{ $str = '
  • '.$this->cording_text($body)."
  • \n"; } $this->cording_last_list_level = $new_level; $this->cording_last_list_type = $new_type; return $str; } function cording_text($str){ global $a_target; $str = preg_replace("/<([^\.=]*)>/", "<$1>", $str); $str = preg_replace("/\*\*([^\*]*)\*\*/", "$1", $str); $str = preg_replace("/\/\/([^\/\[\]\{\}]*)\/\//", "$1", $str); $str = preg_replace("/__([^_]*)__/", "$1", $str); $str = preg_replace("/--([^-]*)--/", "$1", $str); $str = preg_replace("/\[\[http:\/\/([^\|\]]*)\|([^\]]*)\]\]/", '$2', $str); $str = preg_replace("/\[\[http:\/\/([^\|\]]*)\]\]/", '$1', $str); $str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\}\}/", '$1', $str); $str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*)\}\}/", '$1', $str); $str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*)\}\}/", '$1', $str); $str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*) *\}\}/", '$1', $str); $str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*) *\}\}/", '$1', $str); $str = preg_replace("/\{\{http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*) *\}\}/", '$1', $str); $str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\}\}/", '$1', $str); $str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*)\}\}/", '$1', $str); $str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*)\}\}/", '$1', $str); $str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*) +\}\}/", '$1', $str); $str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*) +\}\}/", '$1', $str); $str = preg_replace("/\{\{ +http:\/\/([^\|\}\? ]*)\?([0-9]*)x([0-9]*) +\}\}/", '$1', $str); $str = preg_replace("/< ?\.([^\| ]*) ?\|([^>]*)>/", '$2', $str); $str = preg_replace("/< ?= ?([^\| ]*) ?\|([^>]*)>/", '$2', $str); return $str; } function cording_start($str){ $array = preg_split("/[\r\n]/", $str, -1, PREG_SPLIT_NO_EMPTY); $end = count($array); $result = ''; for ($i=0; $i<$end; $i++){ $line = $array[$i]; if (preg_match("/^(\={2}) ?([^=]*)$/", $line, $data)){ $this->cording_tag_close("h2", FALSE); echo "

    ".$data[2]."

    \n"; }else if (preg_match("/^(\={3}) ?([^=]*)$/", $line, $data)){ $this->cording_tag_close("h3", FALSE); echo "

    ".$data[2]."

    \n"; }else if (preg_match("/^(\={4}) ?([^=]*)$/", $line, $data)){ $this->cording_tag_close("h4", FALSE); echo "

    ".$data[2]."

    \n"; }else if (preg_match("/^(\={5}) ?([^=]*)$/", $line, $data)){ $this->cording_tag_close("h5", FALSE); echo "

    ".$data[2]."

    \n"; }else if (preg_match("/^( {2,3}-) ?(.*)$/", $line, $data)){ echo $this->cording_list(1, 'ol', $data[2]); }else if (preg_match("/^( {4,5}-) ?(.*)$/", $line, $data)){ echo $this->cording_list(2, 'ol', $data[2]); }else if (preg_match("/^( {6,7}-) ?(.*)$/", $line, $data)){ echo $this->cording_list(3, 'ol', $data[2]); }else if (preg_match("/^( {8,9}-) ?(.*)$/", $line, $data)){ echo $this->cording_list(4, 'ol', $data[2]); }else if (preg_match("/^( {2,3}\*) ?(.*)$/", $line, $data)){ echo $this->cording_list(1, 'ul', $data[2]); }else if (preg_match("/^( {4,5}\*) ?(.*)$/", $line, $data)){ echo $this->cording_list(2, 'ul', $data[2]); }else if (preg_match("/^( {6,7}\*) ?(.*)$/", $line, $data)){ echo $this->cording_list(3, 'ul', $data[2]); }else if (preg_match("/^( {8,9}\*) ?(.*)$/", $line, $data)){ echo $this->cording_list(4, 'ul', $data[2]); }else if (preg_match("/^\#([^\.\#]*) ?\.([^\.\#\{]*)\{$/", $line, $data)){ $this->cording_tag_close("div", TRUE); echo '
    '."\n"; }else if (preg_match("/^\.([^\.\#]*) ?\#([^\.\#\{]*)\{$/", $line, $data)){ $this->cording_tag_close("div", TRUE); echo '
    '."\n"; }else if (preg_match("/^\.([^\.\#\{]*)\{$/", $line, $data)){ $this->cording_tag_close("div", TRUE); echo '
    '."\n"; }else if (preg_match("/^\#([^\.\#\{]*)\{$/", $line, $data)){ $this->cording_tag_close("div", TRUE); echo '
    '."\n"; }else if ($line == "}" && in_array("div", $this->cording_open_tags)){ while ($this->cording_open_tags[0] != "div"){ echo 'cording_open_tags).">\n"; } echo 'cording_open_tags).">\n"; }else{ $this->cording_tag_close("p", TRUE); echo "

    \n"; echo $this->cording_text($line)."\n"; } } $this->cording_tag_close("", FALSE); } } ?>