Changeset 20:0da34e6ab266 in misc


Ignore:
Timestamp:
08/20/07 17:00:36 (5 years ago)
Author:
Eriol
Branch:
misc
Convert:
svn:e60e002c-0983-44b9-b2ae-8842d539f768/misc@23
Message:

Added table handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wikka2doku.py

    r19 r20  
    5656        return l 
    5757 
     58def trasftable(mo): 
     59    columns = int(mo.groups()[0]) 
     60    cells =  mo.groups()[1] 
     61    tablestr = '' 
     62 
     63    splitted_cells = cells.split(';') 
     64    heading = splitted_cells[:columns] 
     65    body = splitted_cells[columns:] 
     66    body = zip(*[body[i::columns] for i in range(columns)]) 
     67 
     68    tablestr = '^' + '^'.join(heading) + '^\n' 
     69    for cells in body: 
     70        tablestr += '|' + '|'.join(cells) + '|\n' 
     71 
     72    return tablestr 
     73 
    5874def processBodyPage(body): 
    5975    link = re.compile(r'''\[\[([^\[\]]+?)\s([^\[\]]+?)\]\]''') 
     
    6379    code = re.compile(r'''%%\((.*?)\)(.*?)%%''') 
    6480    bold = re.compile(r'''++(.*?)++''') 
     81    table = re.compile(r'''{{table[ ]+columns="(.*?)".*cells="(.*?)"}}''') 
     82 
    6583    body = body.replace('\\n', '\n') 
    6684    body = body.replace('~~-', '    *') 
     
    7694    body = images.sub(r'{{\1}}', body) 
    7795    body = monospaced.sub(r"''\1''", body) 
    78     body = code.sub(r"<code \1>\2</code>", body) 
    79     body = bold.sub(r"<del>\1</del>", body) 
     96    body = code.sub(r'<code \1>\2</code>', body) 
     97    body = bold.sub(r'<del>\1</del>', body) 
     98    body = table.sub(trasftable, body) 
     99 
    80100    return body 
    81101 
Note: See TracChangeset for help on using the changeset viewer.