Changes between Version 8 and Version 9 of CookBookTemplateFilterBBCode


Ignore:
Timestamp:
Mar 15, 2010, 3:30:49 PM (14 years ago)
Author:
Hede
Comment:

multiple lists

Legend:

Unmodified
Added
Removed
Modified
  • CookBookTemplateFilterBBCode

    v8 v9  
    8585----
    8686I noticed that there is no handling of quote where a user name is given.  phpBB, for example, has {{{[quote="A User's Name"]text[/quote]}}}. ---- Powerlord
     87
     88----
     89
     90While multiple urls, images, b's, etc are no problem, this is not the case with lists. I edited the middle part to the following to achieve this:
     91{{{
     92    temp = ''
     93    p = re.compile(r'\[list\](.+?)\[/list\]', re.DOTALL)
     94    m = p.search(value)
     95    while m:
     96        items = re.split(re.escape('[*]'), m.group(1))
     97        for i in items[1:]:
     98            temp = temp + '<li>' + i + '</li>'
     99        value = p.sub(r'<ul>'+temp+'</ul>', value, 1)
     100        m = p.search(value)
     101        temp = ''
     102    p = re.compile(r'\[list=(.)\](.+?)\[/list\]', re.DOTALL)
     103    m = p.search(value)
     104    while m:
     105        items = re.split(re.escape('[*]'), m.group(2))
     106        for i in items[1:]:
     107            temp = temp + '<li>' + i + '</li>'
     108        value = p.sub(r'<ol type=\1>'+temp+'</ol>', value, 1)
     109        m = p.search(value)
     110        temp = ''
     111    return mark_safe(value)
     112}}}
     113I don't know if this has side effects though... -- Hede
Back to Top