Making Lists in vB XHTML 1.0 Strict Compliant

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Faruk
    Senior Member
    • Aug 2001
    • 1320
    • 3.0.0 'Gold'

    Making Lists in vB XHTML 1.0 Strict Compliant

    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:
    Code:
    <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:

    Code:
    [ list ]    -> <ul><li>
    [ * ]      -> </li><li>
    [ / list ]  -> </li></ul>
    Now you would have this:
    Code:
    <ul>
    <li></li>
    <li> boo </li>
    </ul>
    Then you just add a replacement for "<li></li>" to "". That would create:
    Code:
    <ul>
    <li> boo </li>
    </ul>

    Voila, XHTML 1.0 Strict Standards Compliant Lists.
  • Lumina
    Senior Member
    • Sep 2002
    • 1152
    • 3.5.x

    #2
    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.
    Lumina, aventurière des mondes fantastiques et petite rédactrice au grand cœur
    Cœur Lumière - vBulletin-fr
    Join the vBulletin French community social group!

    Comment

    • Faruk
      Senior Member
      • Aug 2001
      • 1320
      • 3.0.0 'Gold'

      #3
      Originally posted by Lumina
      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 [li] 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] & [/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

      Comment

      • Faruk
        Senior Member
        • Aug 2001
        • 1320
        • 3.0.0 'Gold'

        #4
        Hmm, it depends on where the nl2br() is done, of course... I should look into that...

        Comment

        • Lumina
          Senior Member
          • Sep 2002
          • 1152
          • 3.5.x

          #5
          If you find a way to prevent <br /> from being removed before a[*], please tell me how you changed the code !
          Lumina, aventurière des mondes fantastiques et petite rédactrice au grand cœur
          Cœur Lumière - vBulletin-fr
          Join the vBulletin French community social group!

          Comment

          • Faruk
            Senior Member
            • Aug 2001
            • 1320
            • 3.0.0 'Gold'

            #6
            owkies

            mind you I haven't actually LOOKED at the code of this yet, ever.

            Comment

            • Lumina
              Senior Member
              • Sep 2002
              • 1152
              • 3.5.x

              #7
              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
              Code:
              		$whitespacefind = array(
              [B][COLOR=green]//[/COLOR][/B]			'#([\r\n]+)( )*(\[\*\]|\[/list|\[list|\[indent|\[quote|\[code|\[php)#si',
              			'#(/list\]|/indent\]|/quote\]|/code\]|/php\])( )*([\r\n]+)#si'
              		);
              		$whitespacereplace = array(
              [B][COLOR=green]//[/COLOR][/B]			'\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[/list]
              Code:
              [B][COLOR=green]	$html = preg_replace('#((\r\n)|\n|\r)(\[\*\]|\[/list\])#si', '\3', $html);[/COLOR][/B]
              	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
              Code:
              [B][COLOR=green]//[/COLOR][/B]	return '[*]' . rtrim($text);
              [B][COLOR=green]	return '[*]' . $text;[/COLOR][/B]
              //This line looks really useless, we remove it
              //Then we put back line breaks that we removed before[*] and[/list]
              Code:
              [B][COLOR=green]//[/COLOR][/B]	$text = preg_replace('#<li>(.*)((?=<li>)|</li>)#iU', "\\1\n", $text);
              [B][COLOR=green]	$text = preg_replace('#(\[\*\]|\[/list\])#si', "\n\\1", $text);
              	$text = preg_replace('#\[list\]\n\[\*\]#si', "[list][*]", $text);[/COLOR][/B]
              Lumina, aventurière des mondes fantastiques et petite rédactrice au grand cœur
              Cœur Lumière - vBulletin-fr
              Join the vBulletin French community social group!

              Comment

              • Stadler
                Senior Member
                • Oct 2001
                • 1021
                • 4.2.X

                #8
                Well, anything between [ list ] and the first [ * ] after that could simply be stripped, I suppose:

                PHP Code:
                $text preg_replace("#(\[list\]).*(\[\*\])#iU","\\1\\2",$text); 
                should do the trick
                Hints & Tips:
                [[vB3] More Spiders / Indexers / Archives for vB3 - list]|[List of one-time-emails to ban]


                http://sfx-images.mozilla.org/affili...efox_80x15.png

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...