<?php
/*
!! MAKE SURE YOU SAVE THIS FILE AS .PHP AND NOT .PHPS! !!

Extension Name: Textile
Extension Url: http://michaelraichelson.com/hacks/vanilla/
Description: Textile- A humane web text generator. Repackaged to be used as a Vanilla extension.
Version: 0.4
Author: Michael Raichelson (Vanilla Extension), Jim Riggs (Textile-PHP), Dean Allan (Textile)
Author Url: http://textism.com/tools/textile/
*/
// this throws a small army of "undefined variable" style errors,
// working on cleaning that up. here's the quick hack.
error_reporting(0);
// Create a simple interface for the Textile plugin
class TextileFormatter extends StringFormatter {
    function 
Parse($String$Object$FormatPurpose) {
        if (
$FormatPurpose == agFORMATSTRINGFORDISPLAY) {
            
$textile = new Textile;
            
$output $textile->process($String);
            return 
$this->ProtectString($output);
        } else {
            return 
$String;
        }
    }
    function 
ProtectString ($String) {
    
// this function by Daniel Vena of Vena.net.
    // it helps reduce the risk of cross-site scripting to help patch security holes.
        //$String = str_replace("<", "&lt;", $String);
    
$String html_entity_decode(rawurldecode($String));
    
$replace = array(
        
// Translates flash embedded with <object> tags into anchors
        
"/<object.*?<param\s*name\s*=\s*[\'\"]?movie[\'\"]?\s*value\s*=\s*[\'\"]?([^\'\"\s>]*)[\'\"]?\s*>.*?\/object\s*>/msiS"
                            
=> "<a href=\"$1\">$1</a>",
        
// Translates <embed> into anchors
        
"/<embed.*?src\s*=\s*[\'\"]?([^\'\"\s>]*)[\'\"]?.*?(?:\/>|\/embed\s*>)/msiS"
                            
=> "<a href=\"$1\">$1</a>",
        
// Remove anchors that attempt to run javascript
        
"/<a[^>]*javascript:[^>]*>(.*?)<\/a\s*>/msiS"
                            
=> "$1",
        
// RegExp match                // Replacement text
        
"/script/miS"                 => "&#115;cript",
        
"/on/miS"                 => "&#111;n",
        
"/\r\n/miS"                => "<br />"
    
);
    
$match array_keys($replace);
    
$sub array_values($replace);
    
$String preg_replace($match,$replace,$String);
        return 
$String;
    }
}

// Instantiate the textile object and add it to the string manipulation methods
$TextileFormatter $Context->ObjectFactory->NewObject($Context"TextileFormatter");
$Context->StringManipulator->AddManipulator("Textile"$TextileFormatter);

/*
    ----- original textilephp 2.0.8 source code -----
    see http://jimandlissa.com/project/textilephp for
    more information.
*/

/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

class Textile {
  var 
$options = array();
  var 
$urlre;
  var 
$punct;
  var 
$valignre;
  var 
$tblalignre;
  var 
$halignre;
  var 
$alignre;
  var 
$imgalignre;
  var 
$clstypadre;
  var 
$clstyre;
  var 
$clstyfiltre;
  var 
$codere;
  var 
$blocktags;
  var 
$links = array();
  var 
$repl = array();
  var 
$tmp = array();
  function 
Textile($options = array()) {
    
$this->options $options;
    
$this->options['filters'] = (isset($this->options['filters']) ? $this->options['filters'] : array());
    
$this->options['charset'] = (isset($this->options['charset']) ? $this->options['charset'] : 'iso-8859-1');
    
$this->options['char_encoding'] = (isset($this->options['char_encoding']) ? $this->options['char_encoding'] : 1);
    
$this->options['do_quotes'] = (isset($this->options['do_quotes']) ? $this->options['do_quotes'] : 1);
    
$this->options['trim_spaces'] = (isset($this->options['trim_spaces']) ? $this->options['trim_spaces'] : 0);
    
$this->options['smarty_mode'] = (isset($this->options['smarty_mode']) ? $this->options['smarty_mode'] : 1);
    
$this->options['preserve_spaces'] = (isset($this->options['preserve_spaces']) ? $this->options['preserve_spaaces'] : 0);
    
$this->options['head_offset'] = (isset($this->options['head_offset']) ? $this->options['head_offset'] : 0);

    if (isset(
$this->options['css']) && is_array($this->options['css'])) {
      
$this->css($this->options['css']);
    }
    
$this->options['macros'] = (isset($this->options['macros']) ? $this->options['macros'] : $this->default_macros());
    if (isset(
$this->options['flavor'])) {
      
$this->flavor($this->options['flavor']);
    } else {
      
$this->flavor('xhtml1/css');
    }
    
$this->_create_re();
  }
  function 
set($opt$value NULL) {
    if (
is_array($opt)) {
      foreach (
$opt as $opt => $value) {
        
$this->set($opt$value);
      }
    } else {
      if (
$opt == 'charset') {
        
$this->charset($value);
      } elseif (
$opt == 'css') {
        
$this->css($value);
      } elseif (
$opt == 'flavor') {
        
$this->flavor($value);
      } else {
        
$this->options[$opt] = $value;
      }
    }
  }
  function 
get($opt) {
    return 
$this->options[$opt];
  }
  function 
disable_html($disable_html NULL) {
    if (
$disable_html != NULL) {
      
$this->options['disable_html'] = $disable_html;
    }
    return (isset(
$this->options['disable_html']) ? $this->options['disable_html'] : 0);
  }
  function 
head_offset($head_offset NULL) {
    if (
$head_offset != NULL) {
      
$this->options['head_offset'] = $head_offset;
    }
    return (
$this->options['head_offset'] ? $this->options['head_offset'] : 0);
  }
  function 
flavor($flavor NULL) {
    if (
$flavor != NULL) {
      
$this->options['flavor'] = $flavor;
      if (
preg_match('/^xhtml(\d)?(\D|$)/'$flavor$matches)) {
        if (
$matches[1] == '2') {
          
$this->options['_line_open'] = '<l>';
          
$this->options['_line_close'] = '</l>';
          
$this->options['_blockcode_open'] = '<blockcode>';
          
$this->options['_blockcode_close'] = '</blockcode>';
          
$this->options['css_mode'] = 1;
        } else {
          
// xhtml 1.x
          
$this->options['_line_open'] = '';
          
$this->options['_line_close'] = '<br />';
          
$this->options['_blockcode_open'] = '<pre><code>';
          
$this->options['_blockcode_close'] = '</code></pre>';
          
$this->options['css_mode'] = 1;
        }
      } elseif (
preg_match('/^html/'$flavor)) {
        
$this->options['_line_open'] = '';
        
$this->options['_line_close'] = '<br>';
        
$this->options['_blockcode_open'] = '<pre><code>';
        
$this->options['_blockcode_close'] = '</code></pre>';
        
$this->options['css_mode'] = preg_match('/\/css/'$flavor);
      }
      if (
$this->options['css_mode'] && !isset($this->options['css'])) { $this->_css_defaults(); }
    }
    return 
$this->options['flavor'];
  }
  function 
css($css NULL) {
    if (
$css != NULL) {
      if (
is_array($css)) {
        
$this->options['css'] = $css;
        
$this->options['css_mode'] = 1;
      } else {
        
$this->options['css_mode'] = $css;
        if (
$this->options['css_mode'] && !isset($this->options['css'])) { $this->_css_defaults(); }
      }
    }
    return (
$this->options['css_mode'] ? $this->options['css'] : 0);
  }
  function 
charset($charset NULL) {
    if (
$charset != NULL) {
        
$this->options['charset'] = $charset;
        if (
preg_match('/^utf-?8$/i'$this->options['charset'])) {
          
$this->char_encoding(0);
        } else {
          
$this->char_encoding(1);
        }
    }
    return 
$this->options['charset'];
  }
  function 
docroot($docroot NULL) {
    if (
$docroot != NULL) {
      
$this->options['docroot'] = $docroot;
    }
    return 
$this->options['docroot'];
  }
  function 
trim_spaces($trim_spaces NULL) {
    if (
$trim_spaces != NULL) {
      
$this->options['trim_spaces'] = $trim_spaces;
    }
    return 
$this->options['trim_spaces'];
  }
  function 
filter_param($filter_param NULL) {
    if (
$filter_param != NULL) {
      
$this->options['filter_param'] = $filter_param;
    }
    return 
$this->options['filter_param'];
  }
  function 
preserve_spaces($preserve_spaces NULL) {
    if (
$preserve_spaces != NULL) {
      
$this->options['preserve_spaces'] = $preserve_spaces;
    }
    return 
$this->options['preserve_spaces'];
  }
  function 
filters($filters NULL) {
    if (
$filters != NULL) {
      
$this->options['filters'] = $filters;
    }
    return 
$this->options['filters'];
  }
  function 
char_encoding($char_encoding NULL) {
    if (
$char_encoding != NULL) {
      
$this->options['char_encoding'] = $char_encoding;
    }
    return 
$this->options['char_encoding'];
  }
  function 
handle_quotes($do_quotes NULL) {
    if (
$do_quotes != NULL) {
      
$this->options['do_quotes'] = $do_quotes;
    }
    return 
$this->options['do_quotes'];
  }

  
/**
   * Creates the class variable regular expression patterns used by
   * Textile. They are not initialized in the declaration, because
   * some rely on the others, requiring a @c $this reference.
   *
   * PHP does not have the Perl qr operator to quote or precompile
   * patterns, so to avoid escaping and matching problems, all
   * patterns must use the same delimiter; this implementation uses
   * {}. Every use of these patterns within this class has been
   * changed to use these delimiters. *JHR*
   *
   * @private
   */
  
function _create_re() {
    
// a URL discovery regex. This is from Mastering Regex from O'Reilly.
    // Some modifications by Brad Choate <brad at bradchoate dot com>
    
$this->urlre '(?:
    # Must start out right...
    (?=[a-zA-Z0-9./#])
    # Match the leading part (proto://hostname, or just hostname)
    (?:
        # ftp://, http://, or https:// leading part
        (?:ftp|https?|telnet|nntp)://(?:\w+(?::\w+)?@)?[-\w]+(?:\.\w[-\w]*)+
        |
        (?:mailto:)?[-\+\w]+@[-\w]+(?:\.\w[-\w]*)+
        |
        # or, try to find a hostname with our more specific sub-expression
        (?i: [a-z0-9] (?:[-a-z0-9]*[a-z0-9])? \. )+ # sub domains
        # Now ending .com, etc. For these, require lowercase
        (?-i: com\b
            | edu\b
            | biz\b
            | gov\b
            | in(?:t|fo)\b # .int or .info
            | mil\b
            | net\b
            | org\b
            | museum\b
            | aero\b
            | coop\b
            | name\b
            | pro\b
            | [a-z][a-z]\b # two-letter country codes
        )
    )?

    # Allow an optional port number
    (?: : \d+ )?

    # The rest of the URL is optional, and begins with / . . .
    (?:
     /?
     # The rest are heuristics for what seems to work well
     [^.!,?;:"\'<>()\[\]{}\s\x7F-\xFF]*
     (?:
        [.!,?;:]+  [^.!,?;:"\'<>()\[\]{}\s\x7F-\xFF]+ #\'"
     )*
    )?
)'
;

    
$this->punct '[\!"\#\$%&\'()\*\+,\-\./:;<=>\?@\[\\\\\]\^_`{\|}\~]';
    
$this->valignre '[\-^~]';
    
$this->tblalignre '[<>=]';
    
$this->halignre '(?:<>|[<>=])';
    
$this->alignre '(?:(?:' $this->valignre '|<>' $this->valignre '?|' $this->valignre '?<>|' $this->valignre '?' $this->halignre '?|' $this->halignre '?' $this->valignre '?)(?!\w))';
    
$this->imgalignre '(?:(?:[<>]|' $this->valignre '){1,2})';

    
$this->clstypadre '(?:
  (?:\([A-Za-z0-9_\- \#]+\))
  |
  (?:{
      (?: \( [^)]+ \) | [^\}] )+
     })
  |
  (?:\(+? (?![A-Za-z0-9_\-\#]) )
  |
  (?:\)+?)
  |
  (?: \[ [a-zA-Z\-]+? \] )
)'
;

    
$this->clstyre '(?:
  (?:\([A-Za-z0-9_\- \#]+\))
  |
  (?:{
      [A-Za-z0-9_\-](?: \( [^)]+ \) | [^\}] )+
     })
  |
  (?: \[ [a-zA-Z\-]+? \] )
)'
;

    
$this->clstyfiltre '(?:
  (?:\([A-Za-z0-9_\- \#]+\))
  |
  (?:{
      [A-Za-z0-9_\-](?: \( [^)]+ \) | [^\}] )+
     })
  |
  (?:\|[^\|]+\|)
  |
  (?:\(+?(?![A-Za-z0-9_\-\#]))
  |
  (?:\)+)
  |
  (?: \[ [a-zA-Z]+? \] )
)'
;

    
$this->codere '(?:
    (?:
      [\[{]
      @                           # opening
      (?:\[([A-Za-z0-9]+)\])?     # $1: language id
      (.+?)                       # $2: code
      @                           # closing
      [\]}]
    )
    |
    (?:
      (?:^|(?<=[\s\(]))
      @                           # opening
      (?:\[([A-Za-z0-9]+)\])?     # $3: language id
      ([^\s].+?[^\s])             # $4: code itself
      @                           # closing
      (?:$|(?=' 
$this->punct '{1,2}|\s))
    )
)'
;

    
$this->blocktags '
    <
    (( /? ( h[1-6]
     | p
     | pre
     | div
     | table
     | t[rdh]
     | [ou]l
     | li
     | block(?:quote|code)
     | form
     | input
     | select
     | option
     | textarea
     )
    [ >]
    )
    | !--
    )
'
;
  } 
// function _create_re

  /**
   * Transforms the provided text using Textile markup rules.
   *
   * @param $str The @c string specifying the text to process.
   *
   * @return A @c string containing the processed (X)HTML.
   *
   * @public
   */
  
function process($str) {
    
/*
     * Function names in PHP are case insensitive, so function
     * textile() cannot be redefined.  Thus, this PHP implementation
     * will only use process().
     *
     *   return $this->textile($str);
     * } // function process
     *
     * function textile($str) {
     */

    // quick translator for abbreviated block names
    // to their tag
    
$macros = array('bq' => 'blockquote');

    
// an array to hold any portions of the text to be preserved
    // without further processing by Textile
    
array_unshift($this->repl, array());

    
// strip out extra newline characters. we're only matching for \n herein
    //$str = preg_replace('!(?:\r?\n|\r)!', "\n", $str);
    
$str preg_replace('!(?:\015?\012|\015)!'"\n"$str);

    
// optionally remove trailing spaces
    
if ($this->options['trim_spaces']) { $str preg_replace('/ +$/m'''$str); }

    
// preserve contents of the '==', 'pre', 'blockcode' sections
    
$str preg_replace_callback('{(^|\n\n)==(.+?)==($|\n\n)}s',
                                 
$this->_cb('"$m[1]\n\n" . $me->_repl($me->repl[0], $me->format_block(array("text" => $m[2]))) . "\n\n$m[3]"'), $str);

    if (!
$this->disable_html()) {
      
// preserve style, script tag contents
      
$str preg_replace_callback('!(<(style|script)(?:>| .+?>).*?</\2>)!s'$this->_cb('$me->_repl($me->repl[0], $m[1])'), $str);

      
// preserve HTML comments
      
$str preg_replace_callback('|(<!--.+?-->)|s'$this->_cb('$me->_repl($me->repl[0], $m[1])'), $str);

      
// preserve pre block contents, encode contents by default
      
$pre_start count($this->repl[0]);
      
$str preg_replace_callback('{(<pre(?: [^>]*)?>)(.+?)(</pre>)}s',
                                   
$this->_cb('"\n\n" . $me->_repl($me->repl[0], $m[1] . $me->encode_html($m[2], 1) . $m[3]) . "\n\n"'), $str);
      
// fix code tags within pre blocks we just saved.
      
for ($i $pre_start$i count($this->repl[0]); $i++) {
        
$this->repl[0][$i] = preg_replace('|&lt;(/?)code(.*?)&gt;|s''<$1code$2>'$this->repl[0][$i]);
      }

      
// preserve code blocks by default, encode contents
      
$str preg_replace_callback('{(<code(?: [^>]+)?>)(.+?)(</code>)}s',
                                   
$this->_cb('$me->_repl($me->repl[0], $m[1] . $me->encode_html($m[2], 1) . $m[3])'), $str);

      
// encode blockcode tag (an XHTML 2 tag) and encode it's
      // content by default
      
$str preg_replace_callback('{(<blockcode(?: [^>]+)?>)(.+?)(</blockcode>)}s',
                                   
$this->_cb('"\n\n" . $me->_repl($me->repl[0], $m[1] . $me->encode_html($m[2], 1) . $m[3]) . "\n\n"'), $str);

      
// preserve PHPish, ASPish code
      
$str preg_replace_callback('!(<([\?%]).*?(\2)>)!s'$this->_cb('$me->_repl($me->repl[0], $m[1])'), $str);
    }

    
// pass through and remove links that follow this format
    // [id_without_spaces (optional title text)]url
    // lines like this are stripped from the content, and can be
    // referred to using the "link text":id_without_spaces syntax
    //$links = array();
    
$str preg_replace_callback('{(?:\n|^) [ ]* \[ ([^ ]+?) [ ]*? (?:\( (.+?) \) )?  \] ((?:(?:ftp|https?|telnet|nntp)://|/)[^ ]+?) [ ]* (\n|$)}mx',
                                 
$this->_cb('($me->links[$m[1]] = array("url" => $m[3], "title" => $m[2])) ? $m[4] : $m[4]'), $str);
    
//$this->links = $links;

    // eliminate starting/ending blank lines
    
$str preg_replace('/^\n+/s'''$str1);
    
$str preg_replace('/\n+$/s'''$str1);

    
// split up text into paragraph blocks, capturing newlines too
    
$para preg_split('/(\n{2,})/'$str, -1PREG_SPLIT_DELIM_CAPTURE);
    unset(
$block$bqlang$filter$class$sticky$lines,
          
$style$stickybuff$lang$clear);

    
$out '';

    foreach (
$para as $para) {
      if (
preg_match('/^\n+$/s'$para)) {
        if (isset(
$sticky) && $sticky && $stickybuff) {
          
$stickybuff .= $para;
        } else {
          
$out .= $para;
        }
        continue;
      }

      if (isset(
$sticky) && $sticky) {
        
$sticky++;
      } else {
        unset(
$block);
        unset(
$class);
        
$style '';
        unset(
$lang);
      }

      unset(
$id$cite$align$padleft$padright$lines$buffer);
      if (
preg_match('{^(h[1-6]|p|bq|bc|fn\d+)
                        ((?:' 
$this->clstyfiltre '*|' $this->halignre ')*)
                        (\.\.?)
                        (?::(\d+|' 
$this->urlre '))?\ (.*)$}sx'$para$matches)) {
        if (
$sticky) {
          if (
$block == 'bc') {
            
// close our blockcode section
            
$out preg_replace('/\n\n$/'''$out1);
            
$out .= $this->options['_blockcode_close'] . "\n\n";
          } elseif (
$block == 'bq') {
            
$out preg_replace('/\n\n$/'''$out1);
            
$out .= '</blockquote>' "\n\n";
          } elseif (
$block == 'table') {
            
$table_out $this->format_table(array('text' => $stickybuff));
            if (!
$table_out) { $table_out ''; }
            
$out .= $table_out;
            unset(
$stickybuff);
          } elseif (
$block == 'dl') {
            
$dl_out $this->format_deflist(array('text' => $stickybuff));
            if (!
$dl_out) { $dl_out ''; }
            
$out .= $dl_out;
            unset(
$stickybuff);
          }
          
$sticky 0;
        }
        
// block macros: h[1-6](class)., bq(class)., bc(class)., p(class).
        //warn "paragraph: [[$para]]\n\tblock: $1\n\tparams: $2\n\tcite: $4";
        
$block $matches[1];
        
$params $matches[2];
        
$cite $matches[4];
        if (
$matches[3] == '..') {
          
$sticky 1;
        } else {
          
$sticky 0;
          unset(
$class);
          unset(
$bqlang);
          unset(
$lang);
          
$style '';
          unset(
$filter);
        }
        if (
preg_match('/^h([1-6])$/'$block$matches2)) {
          if (
$this->options['head_offset']) {
            
$block 'h' . ($matches2[1] + $this->options['head_offset']);
          }
        }
        if (
preg_match('{(' $this->halignre '+)}'$params$matches2)) {
          
$align $matches2[1];
          
$params preg_replace('{' $this->halignre '+}'''$params1);
        }
        if (
$params) {
          if (
preg_match('/\|(.+)\|/'$params$matches2)) {
            
$filter $matches2[1];
            
$params preg_replace('/\|.+?\|/'''$params1);
          }
          if (
preg_match('/{([^}]+)}/'$params$matches2)) {
            
$style $matches2[1];
            
$style preg_replace('/\n/'' '$style);
            
$params preg_replace('/{[^}]+}/'''$params);
          }
          if (
preg_match('/\(([A-Za-z0-9_\-\ ]+?)(?:\#(.+?))?\)/'$params$matches2) ||
              
preg_match('/\(([A-Za-z0-9_\-\ ]+?)?(?:\#(.+?))\)/'$params$matches2)) {
            if (
$matches2[1] || $matches2[2]) {
              
$class $matches2[1];
              
$id $matches2[2];
              if (
$class) {
                
$params preg_replace('/\([A-Za-z0-9_\-\ ]+?(#.*?)?\)/'''$params);
              } elseif (
$id) {
                
$params preg_replace('/\(#.+?\)/'''$params);
              }
            }
          }
          if (
preg_match('/(\(+)/'$params$matches2)) {
            
$padleft strlen($matches2[1]);
            
$params preg_replace('/\(+/'''$params1);
          }
          if (
preg_match('/(\)+)/'$params$matches2)) {
            
$padright strlen($matches2[1]);
            
$params preg_replace('/\)+/'''$params1);
          }
          if (
preg_match('/\[(.+?)\]/'$params$matches2)) {
            
$lang $matches2[1];
            if (
$block == 'bc') {
              
$bqlang $lang;
              unset(
$lang);
            }
            
$params preg_replace('/\[.+?\]/'''$params1);
          }
        }
        
// warn "settings:\n\tblock: $block\n\tpadleft: $padleft\n\tpadright: $padright\n\tclass: $class\n\tstyle: $style\n\tid: $id\n\tfilter: $filter\n\talign: $align\n\tlang: $lang\n\tsticky: $sticky";
        
$para $matches[5];
      } elseif (
preg_match('|^<textile#(\d+)>$|'$para$matches)) {
        
$buffer $this->repl[0][$matches[1] - 1];
      } elseif (
preg_match('/^clear([<>]+)?\.$/'$para$matches)) {
        if (
$matches[1] == '<') {
          
$clear 'left';
        } elseif (
$matches[1] == '>') {
          
$clear 'right';
        } else {
          
$clear 'both';
        }
        continue;
      } elseif (isset(
$sticky) && $sticky && $stickybuff &&
                (
$block == 'table' || $block == 'dl')) {
        
$stickybuff .= $para;
        continue;
      } elseif (
preg_match('{^(?:' $this->halignre '|' $this->clstypadre '*)*
                              [\*\#]
                              (?:' 
$this->halignre '|' $this->clstypadre '*)*
                              \ }x'
$para)) {
        
// '*', '#' prefix means a list
        
$buffer $this->format_list(array('text' => $para));
      } elseif (
preg_match('{^(?:table(?:' $this->tblalignre '|' $this->clstypadre '*)*
                              (\.\.?)\s+)?
                              (?:_|' 
$this->alignre '|' $this->clstypadre '*)*\|}x'$para$matches)) {
        
// handle wiki-style tables
        
if ($matches[1] && ($matches[1] == '..')) {
          
$block 'table';
          
$stickybuff $para;
          
$sticky 1;
          continue;
        } else {
          
$buffer $this->format_table(array('text' => $para));
        }
      } elseif (
preg_match('{^(?:dl(?:' $this->clstyre ')*(\.\.?)\s+)}x'$para$matches)) {
        
// handle definition lists
        
if ($matches[1] && ($matches[1] == '..')) {
          
$block 'dl';
          
$stickybuff $para;
          
$sticky 1;
          continue;
        } else {
          
$buffer $this->format_deflist(array('text' => $para));
        }
      }
      if (isset(
$buffer) && $buffer) {
        
$out .= $buffer;
        continue;
      }
      
$lines preg_split('/\n/'$para);
      if ((
count($lines) == 1) && ($lines[0] == '')) {
        continue;
      }

      
$block = (isset($block) ? $block 'p');

      
$buffer '';
      
$pre '';
      
$post '';

      if (
$block == 'bc') {
        if (
$sticky <= 1) {
          
$pre .= $this->options['_blockcode_open'];
          
$pre preg_replace('/>$/s'''$pre1);
          if (
$bqlang) { $pre .= " language=\"$bqlang\""; }
          if (
$align) {
            
$alignment $this->_halign($align);
            if (
$this->options['css_mode']) {
              if ((
$padleft || $padright) &&
                  ((
$alignment == 'left') || ($alignment == 'right'))) {
                
$style .= ';float:' $alignment;
              } else {
                
$style .= ';text-align:' $alignment;
              }
              
$class .= ' ' . ($this->options['css']["class_align_$alignment"] ? $this->options['css']["class_align_$alignment"] : $alignment);
            } else {
              if (
$alignment) { $pre .= " align=\"$alignment\""; }
            }
          }
          if (
$padleft) { $style .= ";padding-left:${padleft}em"; }
          if (
$padright) { $style .= ";padding-right:${padright}em"; }
          if (
$clear) { $style .= ";clear:${clear}"; }
          if (
$class) { $class preg_replace('/^ /'''$class1); }
          if (
$class) { $pre .= " class=\"$class\""; }
          if (
$id) { $pre .=