Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.0.4

Request #5760 [size=(+/-)\d] format not supported
Submitted: 2005-10-23 22:24 UTC
From: me at ben-xo dot com Assigned:
Status: Suspended Package: Text_Wiki_BBCode
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 38 - 5 = ?

 
 [2005-10-23 22:24 UTC] me at ben-xo dot com
Description: ------------ No support for relative sizes in [size], which makes Text_Wiki_BBCode's markup incompatible with vBulletin. Test script: --------------- the correct regex to match size tags is something like [size=((\+|-)?\d+)... Actual result: -------------- [size=+1]...[/size] is rendered instead of as <font size="+1">...</font>

Comments

 [2005-10-24 03:36 UTC] me at ben-xo dot com
I've fixed this to my satisfaction by editing the two following files. Render/Xhtml/Font.php $Id: Font.php,v 1.1 2005/08/06 11:36:45 toggg Exp $ uncomment class var $size function token($options) { if ($options['type'] == 'end') { return '</span>'; } if ($options['type'] != 'start') { return ''; } $ret = '<span style="'; if (isset($options['size'])) { $size = trim($options['size']); if (is_numeric($size)) { switch($options['relative']) { case '+': $size = (100+($size*5)).'%'; break; case '-': $size = (100-($size*5)).'%'; break; default: /* use $size as an index into $this->size */ $size = min(7,$size); $size = max(1,$size); $size = $this->size[$size-1]; } } $ret .= "font-size: $size;"; } return $ret.'">'; } *** Parse/BBCode/Font.php $Id: Font.php,v 1.3 2005/08/11 10:23:50 toggg Exp $ var $regex = "#\[size=(\+|\-|)(\d+)]((?:((?R))|.)*?)\[/size]#msi"; 69: if (array_key_exists(4, $matches)) { 74: $matches[3] 78: $expsub = $matches[3]; 82: $options = array('type' => 'start', 'level' => $this->_level, 'size' => $matches[2], 'relative' => $matches[1]); there. looks lovely in Wordpress now.
 [2005-10-24 06:13 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2005-10-24 12:23 UTC] me at ben-xo dot com
Here is the patch in unified diff format. diff -ur Text_Wiki-1.0.1/Text/Wiki/Render/Xhtml/Font.php Text_Wiki-1.0.1-benxo/Text/Wiki/Render/Xhtml/Font.php --- Text_Wiki-1.0.1/Text/Wiki/Render/Xhtml/Font.php 2005-08-06 12:36:46.000000000 +0100 +++ Text_Wiki-1.0.1-benxo/Text/Wiki/Render/Xhtml/Font.php 2005-10-24 13:10:58.000000000 +0100 @@ -28,7 +28,7 @@ */ class Text_Wiki_Render_Xhtml_Font extends Text_Wiki_Render { -/* var $size = array( + var $size = array( 'xx-small', 'x-small', 'small', @@ -49,7 +49,7 @@ 'pt', 'pc' ); -*/ + /** * Renders a token into text matching the requested format. @@ -70,9 +70,25 @@ $ret = '<span style="'; if (isset($options['size'])) { + + // size between 1 and 7 $size = trim($options['size']); + $size = min(7,max(1,$size)); + if (is_numeric($size)) { - $size .= 'px'; + switch($options['relative']) { + // relative size: from 65% to 135% + case '+': + $size = (100+($size*5)).'%'; + break; + case '-': + $size = (100-($size*5)).'%'; + break; + + // default: use $size as an index into $this->size for an absolute size + default: + $size = $this->size[$size-1]; + } } $ret .= "font-size: $size;"; } diff -ur Text_Wiki_BBCode-0.0.1/Text/Wiki/Parse/BBCode/Font.php Text_Wiki_BBCode-0.0.1-benxo/Text/Wiki/Parse/BBCode/Font.php --- Text_Wiki_BBCode-0.0.1/Text/Wiki/Parse/BBCode/Font.php 2005-08-11 11:23:50.000000000 +0100 +++ Text_Wiki_BBCode-0.0.1-benxo/Text/Wiki/Parse/BBCode/Font.php 2005-10-24 03:49:59.000000000 +0100 @@ -41,7 +41,7 @@ * @var string * @see parse() */ - var $regex = "#\[size=(\d+)]((?:((?R))|.)*?)\[/size]#msi"; + var $regex = "#\[size=(\+|\-|)(\d+)]((?:((?R))|.)*?)\[/size]#msi"; /** * The current font nesting depth, starts by zero @@ -66,20 +66,20 @@ function process(&$matches) { // nested block ? - if (array_key_exists(3, $matches)) { + if (array_key_exists(4, $matches)) { $this->_level++; $expsub = preg_replace_callback( $this->regex, array(&$this, 'process'), - $matches[2] + $matches[3] ); $this->_level--; } else { - $expsub = $matches[2]; + $expsub = $matches[3]; } // builds the option array - $options = array('type' => 'start', 'level' => $this->_level, 'size' => $matches[1]); + $options = array('type' => 'start', 'level' => $this->_level, 'size' => $matches[2], 'relative' => $matches[1]); $statok = $this->wiki->addToken($this->rule, $options); $options['type'] = 'end'; return $statok . $expsub . $this->wiki->addToken($this->rule, $options);
 [2006-10-17 01:15 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!