View Full Version : Making Lists in vB XHTML 1.0 Strict Compliant
Faruk
Fri 8th Aug '03, 6:44am
For those who care, here is a way to have LISTS in vBulletin be strict standards compliant (XHTML 1), and it requires only a little bit of hacking :)
Currently:
[ list ]
[ * ] boo
[ / list ]
would create:
<ul>
<li> boo
</ul>
which will not pass the validator for lacking a </li> tag. If you'd hack the [ list ] code replacement bits, you could do this:
[ list ] -> <ul><li>
[ * ] -> </li><li>
[ / list ] -> </li></ul>
Now you would have this:
<ul>
<li></li>
<li> boo </li>
</ul>
Then you just add a replacement for "<li></li>" to "". That would create:
<ul>
<li> boo </li>
</ul>
Voila, XHTML 1.0 Strict Standards Compliant Lists. :)
Lumina
Mon 11th Aug '03, 10:07am
With this :
[ list ]
[ * ] boo
[ / list ]
You mean you would have this :
<list><li><br /></li><li>boo<br /></li></list>
You need to remove <li></li>, but <li><br /></li> and <li><br /><br /></li> too. In short, remove <li>(<br />)*</li>.
Also, adding the easy [li] tag will help you with missing line breaks.
Faruk
Mon 11th Aug '03, 10:44am
With this :
[ list ]
[ * ] boo
[ / list ]
You mean you would have this :
<list><li><br /></li><li>boo<br /></li></list>
You need to remove <li></li>, but <li><br /></li> and <li><br /><br /></li> too. In short, remove <li>(<br />)*</li>.
Also, adding the easy [li] tag will help you with missing line breaks.
Hmyeah, good point about the removal and <br />'s.
However, using the tag will only be of use WHEN YOUR USERS ACTUALLY USE IT, and since it's much easier for them to use or the vBQuick Code buttons for Lists (which uses as well), you shouldn't rely on it. Also, it doesn't save you from existing posts that have . :)
If all of my users would only be able to use [li] & for lists, I'd consider it, but right now, I prefer my slight alteration to the parser to make sure, 100%, that it's valid :)
Faruk
Mon 11th Aug '03, 10:46am
Hmm, it depends on where the nl2br() is done, of course... I should look into that...
Lumina
Mon 11th Aug '03, 10:54pm
If you find a way to prevent <br /> from being removed before a , please tell me how you changed the code ! :)
Faruk
Tue 12th Aug '03, 3:50am
owkies :)
mind you I haven't actually LOOKED at the code of this yet, ever. :)
Lumina
Thu 21st Aug '03, 5:49pm
Got a solution to resolve the issue with lists in Beta 5.
Watch closely.
File functions_bbcodeparse.php
//Comment the two following lines to avoid lines being removed before block elements
$whitespacefind = array(
// '#([\r\n]+)( )*(\[\*\]|\[/list|\|/indent\]|/quote\]|/code\]|/php\])( )*([\r\n]+)#si'
);
$whitespacereplace = array(
// '\3',
'\1'
);
File functions_wysiwyg.php
//The IE Wysiwyg has a bug, it displays too much lines.
//So we remove a line before each and
$html = preg_replace('#((\r\n)|\n|\r)(\[\*\]|\[/list\])#si', '\3', $html);
return parse_bbcode($html, $forumid, $allowsmilie, '', 0, 1);
//Remove the use of rtrim() to avoid line breaks being removed at the end of each element
// return ' ' . rtrim($text);
return ' ' . $text;
//This line looks really useless, we remove it
//Then we put back line breaks that we removed before and [/list]
// $text = preg_replace('#<li>(.*)((?=<li>)|</li>)#iU', "\\1\n", $text);
$text = preg_replace('#(\[\*\]|\[/list\])#si', "\n\\1", $text);
$text = preg_replace('#\[list\]\n\[\*\]#si', "[list] ", $text);
Stadler
Sat 23rd Aug '03, 1:36pm
Well, anything between [ list ] and the first [ * ] after that could simply be stripped, I suppose:
$text = preg_replace("#(\[list\]).*(\[\*\])#iU","\\1\\2",$text);should do the trick :)
Powered by vBulletin™ Version 4.0.0 Beta 4 Copyright © 2009 vBulletin Solutions, Inc. All rights