list_state) { case LIST_NONE: break; case LIST_UNORDERED: $ltag = "\n"; break; case LIST_ORDERED: $ltag = "\n"; break; case LIST_DEFINITION: $ltag = "\n"; break; } $this->list_state = LIST_NONE; switch ($state) { case STATE_PARAGRAPH: return "$ltag
\n"; break; case STATE_BLOCKQUOTE: return "$ltag\n"; break; case STATE_PREFORM: return "$ltag\n"; break; case STATE_NOTIKI: return "$ltag\n"; break; } } function do_replace( $line, $mark, $tag ) { // do the regex thingy for things like bold, italic etc // $mark is the magic character, and $tag the HTML tag to insert $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'($| |[.,;:)])'; $replace = '\\1<'.$tag.'>\\2'.$tag.'>\\3'; return eregi_replace( $regex, $replace, $line ); } function do_list( $line ) { // handle line with list character on it // get magic character and then delete it from the line $listchar = $line{0}; $line = eregi_replace( "^[*#;:] ", "", $line ); // if not in "list mode" then we need to drop the appropriate start tag $tag = ""; if ($this->list_state == LIST_NONE) { switch ($listchar) { case '*': $tag = "\n"; $buffer = $buffer . $this->line_replace( eregi_replace( "^>","",$line) ). "\n"; $this->block_state = STATE_BLOCKQUOTE; } else if (eregi( "^ ",$line) ) { // preformatted text $buffer = $buffer . "\n"; $buffer = $buffer . $this->line_replace($line) . "\n"; $this->block_state = STATE_PREFORM; } else if (eregi("^\% ",$line) ) { // preformatted text - no processing $buffer = $buffer . "\n"; $buffer = $buffer . eregi_replace( "^\%","",$line) . "\n"; $this->block_state = STATE_NOTIKI; } else { // ordinary paragraph $buffer = $buffer . "\n"; $buffer = $buffer . $this->line_replace($line) . "\n"; $this->block_state = STATE_PARAGRAPH; } continue; } if (($this->block_state == STATE_PARAGRAPH) | ($this->block_state == STATE_BLOCKQUOTE) | ($this->block_state == STATE_PREFORM) ) { $buffer = $buffer . $this->line_replace($line) . "\n"; continue; } elseif ($this->block_state == STATE_NOTIKI) { $buffer = $buffer . $line . "\n"; } } // close off any block level tags $buffer = $buffer . $this->close_block( $this->block_state ); return $buffer; } } ?>