process($text);
}
function smarty_modifier_textile($text) {
return Textile($text);
}
/**
* The Textile class serves as a wrapper for all Textile
* functionality. It is not inherently necessary that Textile be a
* class; however, this is as close as one can get to a namespace in
* PHP. Wrapping the functionality in a class prevents name
* collisions and dirtying of the global namespace. The Textile class
* uses no global variables and will not have any side-effects on
* other code.
*
* @brief Class wrapper for the Textile functionality.
*/
class Textile {
/**
* The @c array containing all of the Textile options for this
* object.
*
* @private
*/
var $options = array();
/**
* The @c string containing the regular expression pattern for a
* URL. This variable is initialized by @c _create_re() which is
* called in the contructor.
*
* @private
*/
var $urlre;
/**
* The @c string containing the regular expression pattern for
* punctuation characters. This variable is initialized by
* @c _create_re() which is called in the contructor.
*
* @private
*/
var $punct;
/**
* The @c string containing the regular expression pattern for the
* valid vertical alignment codes. This variable is initialized by
* @c _create_re() which is called in the contructor.
*
* @private
*/
var $valignre;
/**
* The @c string containing the regular expression pattern for the
* valid table alignment codes. This variable is initialized by
* @c _create_re() which is called in the contructor.
*
* @private
*/
var $tblalignre;
/**
* The @c string containing the regular expression pattern for the
* valid horizontal alignment codes. This variable is initialized by
* @c _create_re() which is called in the contructor.
*
* @private
*/
var $halignre;
/**
* The @c string containing the regular expression pattern for the
* valid alignment codes. This variable is initialized by
* @c _create_re() which is called in the contructor.
*
* @private
*/
var $alignre;
/**
* The @c string containing the regular expression pattern for the
* valid image alignment codes. This variable is initialized by
* @c _create_re() which is called in the contructor.
*
* @private
*/
var $imgalignre;
/**
* The @c string containing the regular expression pattern for a
* class, ID, and/or padding specification. This variable is
* initialized by @c _create_re() which is called in the contructor.
*
* @private
*/
var $clstypadre;
/**
* The @c string containing the regular expression pattern for a
* class and/or ID specification. This variable is initialized by
* @c _create_re() which is called in the contructor.
*
* @private
*/
var $clstyre;
/**
* The @c string containing the regular expression pattern for a
* class, ID, and/or filter specification. This variable is
* initialized by @c _create_re() which is called in the contructor.
*
* @private
*/
var $clstyfiltre;
/**
* The @c string containing the regular expression pattern for a
* code block. This variable is initialized by @c _create_re() which
* is called in the contructor.
*
* @private
*/
var $codere;
/**
* The @c string containing the regular expression pattern for all
* block tags. This variable is initialized by @c _create_re() which
* is called in the contructor.
*
* @private
*/
var $blocktags;
/**
* The @c array containing the list of lookup links.
*
* @private
*/
var $links = array();
/**
* The @c array containing array
s of replacement blocks
* of text that are temporary removed from the input text to avoid
* processing. Different functions use this replacement
* functionality, and each shifts its own replacement array into
* position 0 and removes it when finished. This avoids having
* several replacement variables and/or functions clobbering
* eachothers' replacement blocks.
*
* @private
*/
var $repl = array();
/**
* The @c array containing temporary string
s used in
* replacement callbacks. *JHR*
*
* @private
*/
var $tmp = array();
/**
* Instantiates a new Textile object. Optional options
* can be passed to initialize the object. Attributes for the
* options key are the same as the get/set method names
* documented here.
*
* @param $options The @c array specifying the options to use for
* this object.
*
* @public
*/
function Textile($options = array()) {
$this->options = $options;
$this->options['filters'] = ($this->options['filters'] ? $this->options['filters'] : array());
$this->options['charset'] = ($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 (is_array($this->options['css'])) {
$this->css($this->options['css']);
}
$this->options['macros'] = ($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 Textile
// getter/setter methods...
/**
* Used to set Textile attributes. Attribute names are the same
* as the get/set method names documented here.
*
* @param $opt A @c string specifying the name of the option to
* change or an @c array specifying options and values.
* @param $value The value for the provided option name.
*
* @public
*/
function set($opt, $value = NULL) {
if (is_array($opt)) {
foreach ($opt as $opt => $value) {
$this->set($opt, $value);
}
} else {
// the following options have special set methods
// that activate upon setting:
if ($opt == 'charset') {
$this->charset($value);
} elseif ($opt == 'css') {
$this->css($value);
} elseif ($opt == 'flavor') {
$this->flavor($value);
} else {
$this->options[$opt] = $value;
}
}
} // function set
/**
* Used to get Textile attributes. Attribute names are the same
* as the get/set method names documented here.
*
* @param $opt A @c string specifying the name of the option to get.
*
* @return The value for the provided option.
*
* @public
*/
function get($opt) {
return $this->options[$opt];
} // function get
/**
* Gets or sets the "disable html" control, which allows you to
* prevent HTML tags from being used within the text processed.
* Any HTML tags encountered will be removed if disable html is
* enabled. Default behavior is to allow HTML.
*
* @param $disable_html If provided, a @c bool indicating whether or
* not this object should disable HTML.
*
* @return A true value if this object disables HTML; a false value
* otherwise.
*
* @public
*/
function disable_html($disable_html = NULL) {
if ($disable_html != NULL) {
$this->options['disable_html'] = $disable_html;
}
return ($this->options['disable_html'] ? $this->options['disable_html'] : 0);
} // function disable_html
/**
* Gets or sets the relative heading offset, which allows you to
* change the heading level used within the text processed. For
* example, if the heading offset is '2' and the text contains an
* 'h1' block, an \
';
$this->options['_blockcode_close'] = '
';
$this->options['css_mode'] = 1;
}
} elseif (preg_match('/^html/', $flavor)) {
$this->options['_line_open'] = '';
$this->options['_line_close'] = '';
$this->options['_blockcode_close'] = '
';
$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 flavor
/**
* Gets or sets the css support for Textile. If css is enabled,
* Textile will emit CSS rules. You may pass a 1 or 0 to enable
* or disable CSS behavior altogether. If you pass an associative array,
* you may assign the CSS class names that are used by
* Textile. The following key names for such an array are
* recognized:
*
* ,
* \ blocks or \