2008-07-09, 01:31 PM
if you tried to validate this post
you will see this error
it's becuase of parsing a div tag inside <strong> tag..
so I would like to make the following changes to inc/class_parser.php
find
find
find
for me I test it, and it's fix any invalid html parsing..
what you think?
you will see this error
Line 246, Column 48: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag.
<u><strong><div style="text-align: center;">test this</div></strong></u>
it's becuase of parsing a div tag inside <strong> tag..
so I would like to make the following changes to inc/class_parser.php
find
$standard_mycode['b']['regex'] = "#\[b\](.*?)\[/b\]#si";
$standard_mycode['b']['replacement'] = "<strong>$1</strong>";
$standard_mycode['u']['regex'] = "#\[u\](.*?)\[/u\]#si";
$standard_mycode['u']['replacement'] = "<u>$1</u>";
$standard_mycode['i']['regex'] = "#\[i\](.*?)\[/i\]#si";
$standard_mycode['i']['replacement'] = "<em>$1</em>";
replace with $standard_mycode['b']['regex'] = "#\[b\](.*?)\[/b\]#si";
$standard_mycode['b']['replacement'] = "<div style=\"font-weight:bold;display: inline;\">$1</div>";
$standard_mycode['u']['regex'] = "#\[u\](.*?)\[/u\]#si";
$standard_mycode['u']['replacement'] = "<div style=\"text-decoration:underline;display: inline;\">$1</div>";
$standard_mycode['i']['regex'] = "#\[i\](.*?)\[/i\]#si";
$standard_mycode['i']['replacement'] = "<div style=\"font-style:italic;display: inline;\">$1</div>";
find
$standard_mycode['color']['regex'] = "#\[color=([a-zA-Z]*|\#?[0-9a-fA-F]{6})](.*?)\[/color\]#si";
$standard_mycode['color']['replacement'] = "<span style=\"color: $1;\">$2</span>";
$standard_mycode['size']['regex'] = "#\[size=(xx-small|x-small|small|medium|large|x-large|xx-large)\](.*?)\[/size\]#si";
$standard_mycode['size']['replacement'] = "<span style=\"font-size: $1;\">$2</span>";
$standard_mycode['size_int']['regex'] = "#\[size=([0-9\+\-]+?)\](.*?)\[/size\]#esi";
$standard_mycode['size_int']['replacement'] = "\$this->mycode_handle_size(\"$1\", \"$2\")";
$standard_mycode['font']['regex'] = "#\[font=([a-z ]+?)\](.+?)\[/font\]#si";
$standard_mycode['font']['replacement'] = "<span style=\"font-family: $1;\">$2</span>";
$standard_mycode['align']['regex'] = "#\[align=(left|center|right|justify)\](.*?)\[/align\]#si";
$standard_mycode['align']['replacement'] = "<div style=\"text-align: $1;\">$2</div>";
replace with$standard_mycode['size']['regex'] = "#\[size=(xx-small|x-small|small|medium|large|x-large|xx-large)\](.*?)\[/size\]#si";
$standard_mycode['size']['replacement'] = "<div style=\"font-size: $1;display: inline;\">$2</div>";
$standard_mycode['size_int']['regex'] = "#\[size=([0-9\+\-]+?)\](.*?)\[/size\]#esi";
$standard_mycode['size_int']['replacement'] = "\$this->mycode_handle_size(\"$1\", \"$2\")";
$standard_mycode['font']['regex'] = "#\[font=([a-z ]+?)\](.+?)\[/font\]#si";
$standard_mycode['font']['replacement'] = "<div style=\"font-family: $1;display: inline;\">$2</div>";
$standard_mycode['align']['regex'] = "#\[align=(left|center|right|justify)\](.*?)\[/align\]#si";
$standard_mycode['align']['replacement'] = "<div style=\"text-align: $1; \">$2</div>";
find
function mycode_handle_size($size, $text)
{
$size = intval($size)+10;
if($size > 50)
{
$size = 50;
}
$text = "<span style=\"font-size: {$size}pt\">".str_replace("\'", "'", $text)."</span>";
return $text;
}
replace with function mycode_handle_size($size, $text)
{
$size = intval($size)+10;
if($size > 50)
{
$size = 50;
}
$text = "<div style=\"font-size: {$size}pt; display: inline;\">".str_replace("\'", "'", $text)."</div>";
return $text;
}
for me I test it, and it's fix any invalid html parsing..
what you think?