Someting about your HTML_BBCodeParser ,Stijn de Reede
| From: | 深空 | Date: | Mon, 22 Mar 2004 05:56:43 +0000 |
| Subject: | Someting about your HTML_BBCodeParser ,Stijn de Reede | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-26621@lists.php.net to get a copy of this message | ||
Stijn de Reede,hello!
I add a HighLight Class For your HTML_BBCodeParser , your codes is very good , but I think it may
has more function . Such as PHP HighLigh , HTML HighLigh , CSS HighLigh , Run code , Flash , Music
..... and so on ....My English is not good . I am hard to read the Code note . :) I don't kown
how to add this function in your Class , follow is the PHP Highlight . but has some mistake , I
don't know why :
[php]<?php phpinfo(); ?>[/php]
Output is
<code><font color="#000000">
<br /><table width="100%"><tr><td
align="center"><table width="90%" cellspacing="0"
cellpadding="0" border="0" style="padding: 10px;"><tr><td
align="left" class="code"><font color="#0000BB"><?php
phpinfo</font><font color="#007700">(); </font><font
color="#0000BB">?></font></td></tr></table></td></tr></table><br
/></font>
</code>
I don't know why it add <code><font color="#000000"> .......
</font></code> itself ....
And some other problem :
[php]
<?php
phpinfo();
echo "[url]http://www.php.net[/url]";
?>
[/php]
the output is :
<code><font color="#000000">
<br /><table width="100%"><tr><td
align="center"><table width="90%" cellspacing="0"
cellpadding="0" border="0" style="padding: 10px;"><tr><td
align="left" class="code">
<br /><font color="#0000BB"><?php
<br />
<br /> phpinfo</font><font
color="#007700">();
<br /> echo </font><font
color="#DD0000">"[url=http://www.php.net]http://www.php.net[/url]"</font><font
color="#007700">;
<br />
<br /></font><font color="#0000BB">?>
<br
/></font></td></tr></table></td></tr></table><br
/></font>
</code>
Not :
<code><font color="#000000">
<br /><table width="100%"><tr><td
align="center"><table width="90%" cellspacing="0"
cellpadding="0" border="0" style="padding: 10px;"><tr><td
align="left" class="code">
<br /><font color="#0000BB"><?php
<br />
<br /> phpinfo</font><font
color="#007700">();
<br /> echo </font><font
color="#DD0000">"[url]http://www.php.net[/url]"</font><font
color="#007700">;
<br />
<br /></font><font color="#0000BB">?>
<br
/></font></td></tr></table></td></tr></table><br
/></font>
</code>
Why does it do this??
The Highlight Class :
<?php
require_once('HTML/BBCodeParser.php');
class HTML_BBCodeParser_Filter_Highlight extends HTML_BBCodeParser
{
/**
* An array of tags parsed by the engine
*
* @access private
* @var array
*/
var $_definedTags = array(
'php' => array( 'htmlopen' => 'br
/><table width="100%"><tr><td align="center"><table
width="90%" cellspacing="0" cellpadding="0" border="0"
style="padding: 10px;"><tr><td align="left"
class="code"',
'htmlclose' =>
'td></tr></table></td></tr></table><br /',
'allowed' => 'none',
'attributes'=> array()),
);
function _preparse()
{
$options = PEAR::getStaticProperty('HTML_BBCodeParser','_options');
$o = $options['open'];
$c = $options['close'];
$oe = $options['open_esc'];
$ce = $options['close_esc'];
$str = stripslashes($this->_text);
$str = highlight_string($str, true);
$this->_preparsed = $str;
}
}
?>
深空(Kim)
kim@openphp.cn
2004-03-22