def htmltables(tables):
    # use py-wikimarkup
    from wikimarkup.parser import Parser
    parser = Parser()
    for table in tables:
        tablelines = table.lines
        tablestring = '\n'.join(tablelines)
        tablestring = re.sub(r'[*][*](.*?)[*][*]', r'<b>\1</b>', tablestring)
        html = parser.parse(tablestring)
        html = html.replace('~', '<br/>')
        #html = adjust_html(html)
        table.html = html
Exemple #2
0
from __future__ import print_function
from builtins import str
from wikimarkup.parser import Parser
import re
from wikitools import wiki, api

parser = Parser()


def galleryTagHook(parser_env, body, attributes={}):
    widths = attributes.get('widths')
    if widths:
        widths = re.sub('px', '', widths)
        gal_width = int(widths)
    else:
        gal_width = 155

    heights = attributes.get('heights')
    if heights:
        heights = re.sub('px', '', heights)
        def_image = int(heights)
    else:
        def_image = 120

    start_text = ''
    if attributes.get('mode', None) == 'packed':
        start_text = '<ul class="gallery mw-gallery-packed">'
        files = body.split('\n')
        for file in files:
            if file.strip() != '':
                res = file.split('|')