Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

BBCode doesn't support numeric lists?

BBCode doesn't support numeric lists?

Answers

  • is that a question or a statement with a question mark?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • In English, question marks denote questions.

  • peregrineperegrine MVP
    edited January 2014

    ok. my english is rusty.

    I wasn't sure if you were telling us it doesn't work, and won't work based on bbcode.
    or if you were wondering if it does work with bbcode.

    version vanilla using you?

    not sure?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    http://area51.phpbb.com/phpBB/faq.php?mode=bbcode#f3r1

    Generating lists
    
    Creating an Unordered list
    BBCode supports two types of lists, unordered and ordered. They are essentially the same as their HTML equivalents. An unordered list outputs each item in your list sequentially one after the other indenting each with a bullet character. To create an unordered list you use [list][/list] and define each item within the list using [*]. For example to list your favourite colours you could use:
    
    [list]
    [*]Red
    [*]Blue
    [*]Yellow
    [/list]
    
    This would generate the following list:
    Red
    Blue
    Yellow
    Creating an Ordered list
    The second type of list, an ordered list, gives you control over what is output before each item. To create an ordered list you use [list=1][/list] to create a numbered list or alternatively [list=a][/list] for an alphabetical list. As with the unordered list, items are specified using [*]. For example:
    
    [list=1]
    [*]Go to the shops
    [*]Buy a new computer
    [*]Swear at computer when it crashes
    [/list]
    
    will generate the following:
    Go to the shops
    Buy a new computer
    Swear at computer when it crashes
    Whereas for an alphabetical list you would use:
    
    [list=a]
    [*]The first possible answer
    [*]The second possible answer
    [*]The third possible answer
    [/list]
    
    giving
    The first possible answer
    The second possible answer
    The third possible answer
    
  • BilgeBilge New
    edited January 2014

    [list=1] and [list=a] does not work on Vanilla 2.0.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
  • @Bilge said:
    [list=1] and [list=a] does not work on Vanilla 2.0.

    well stated. are you using any plugins related to bbcode.

    I don't have a plugin.

    but a core change in class.format.php

     $Mixed2 = preg_replace_callback("#\[list=1\](.*?)\[/list\]#si",array('Gdn_Format', 'ListCallback2'),$Mixed2);
    
    
    
     protected static function ListCallback2($Matches) {
          $Content = explode("[*]", $Matches[1]);
          $Result = '';
          foreach ($Content as $Item) {
             if (trim($Item) != '') $Result .= '<li>'.$Item.'</li>';
          }
          $Result = '<ol>'.$Result.'</ol>';
          return $Result;
       }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited January 2014

    no the formatter has code that checks for bbcode and always returns ul not ol.

     $Mixed2 = preg_replace_callback("#\[list\](.*?)\[/list\]#si",array('Gdn_Format', 'ListCallback'),$Mixed2);
    
      protected static function ListCallback($Matches) {
          $Content = explode("[*]", $Matches[1]);
          $Result = '';
          foreach ($Content as $Item) {
             if (trim($Item) != '') $Result .= '<li>'.$Item.'</li>';
          }
          $Result = '<ul>'.$Result.'</ul>';
          return $Result;
       }
    
    
    I just added another function call and function   to work with numbered lists.
    
    
    
         $Mixed2 = preg_replace_callback("#\[list=1\](.*?)\[/list\]#si",array('Gdn_Format', 'ListCallback2'),$Mixed2);
        protected static function ListCallback2($Matches) {
        $Content = explode("[*]", $Matches[1]);
        $Result = '';
        foreach ($Content as $Item) {
        if (trim($Item) != '') $Result .= '<li>'.$Item.'</li>';
        }
        $Result = '<ol>'.$Result.'</ol>';
        return $Result;
        }
    
    
    
    
    
    using the replace for letters doesn;t seem to work when changing to from "#\[list=a\]
      $Result = '<ol type="a">'.$Result.'</ol>';
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Bilge could write easily himself a plugin, to replace the bbcode at least for ordered lists as well as report it on github.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • There is already NBBC formatter, and you can create you own.

    Note bbcode is not a standard, there is no guarantee everything you are used to will work, such as tables.

    That is why I recommend markdown and or html, with a good editor.

    grep is your friend.

  • @peregrine said:
    Bilge could write easily himself a plugin, to replace the bbcode at least for ordered lists as well as report it on github.

    if you are going to do that submit a pull request. There are more likely to include it if someone contributes.

    Also you don't need two callbacks you can match all list then parse it accordingly.

    e.g. [list(=[a-z1-9])?](.*?)\[/list\]#si

    grep is your friend.

  • good point x00. Bilge can proceed as Bilge desires.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.