from . import tool import datetime import html import re def nowiki_js(data): return re.sub('^\n', '', data.replace('\\', '\\\\').replace('"', '\\"').replace('\r', '')).replace('\n', '
') def link_fix(main_link): global end_data main_link = main_link.replace(''', "") if re.search('^:', main_link): main_link = re.sub('^:', '', main_link) main_link = re.sub('^사용자:', 'user:', main_link) main_link = re.sub('^파일:', 'file:', main_link) main_link = re.sub('^분류:', 'category:', main_link) other_link = re.search('[^\\\\]?(#[^#]+)$', main_link) if other_link: other_link = other_link.groups()[0] main_link = re.sub('(#[^#]+)$', '', main_link) else: other_link = '' main_link = main_link.replace("", "'") main_link = re.sub('\\\\#', '%23', main_link) find_data = re.findall('', main_link) for i in find_data: main_link = main_link.replace('', end_data[i]) find_data = re.findall('', other_link) for i in find_data: other_link = other_link.replace('', end_data[i]) return [main_link, other_link] def table_parser(data, cel_data, cel_num, start_data, num = 0, cel_color = {}): table_class = 'class="' div_style = 'style="' all_table = 'style="' cel_style = 'style="' row_style = 'style="' row = '' cel = 'colspan="' + str(round(len(start_data) / 2)) + '"' if not cel_num in cel_color: cel_color[cel_num] = '' cel_style += cel_color[cel_num] if num == 0: if re.search('^ ', cel_data) and re.search(' $', cel_data): cel_style += 'text-align: center;' elif re.search('^ ', cel_data): cel_style += 'text-align: right;' elif re.search(' $', cel_data): cel_style += 'text-align: left;' table_state = re.findall('<((?:(?!>).)+)>', data) for in_state in table_state: if re.search("^table ?width=([^=]+)$", in_state): table_data = re.sub('^table ?width=', '', in_state) div_style += 'width: ' + ((table_data + 'px') if re.search('^[0-9]+$', table_data) else table_data) + ';' all_table += 'width: 100%;' elif re.search("^table ?height=([^=]+)$", in_state): table_data = re.sub('^table ?height=', '', in_state) div_style += 'height: ' + ((table_data + 'px') if re.search('^[0-9]+$', table_data) else table_data) + ';' elif re.search("^table ?align=([^=]+)$", in_state): table_data = re.sub('^table ?align=', '', in_state) if table_data == 'right': div_style += 'float: right;' elif table_data == 'center': all_table += 'margin: auto;' elif re.search("^table ?textalign=([^=]+)$", in_state): num = 1 table_data = re.sub('^table ?textalign=', '', in_state) if table_data == 'right': all_table += 'text-align: right;' elif table_data == 'center': all_table += 'text-align: center;' elif re.search("^row ?textalign=([^=]+)$", in_state): table_data = re.sub('^row ?textalign=', '', in_state) if table_data == 'right': row_style += 'text-align: right;' elif table_data == 'center': row_style += 'text-align: center;' else: row_style += 'text-align: left;' elif re.search('^-([0-9]+)$', in_state): cel = 'colspan="' + re.sub('^-', '', in_state) + '"' elif re.search("^(\^|v)?\|([^|]+)$", in_state): if re.search('^\^', in_state): cel_style += 'vertical-align: top;' elif re.search('^v', in_state): cel_style += 'vertical-align: bottom;' row = 'rowspan="' + re.sub('^(\^|v)?\|', '', in_state) + '"' elif re.search("^row ?bgcolor=([^=]+)$", in_state): table_data = re.sub('^row ?bgcolor=', '', in_state) row_style += 'background: ' + (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) + ';' elif re.search("^row ?color=([^=]+)$", in_state): table_data = re.sub('^row ?color=', '', in_state) row_style += 'color: ' + (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) + ';' elif re.search("^table ?bordercolor=([^=]+)$", in_state): table_data = re.sub('^table ?bordercolor=', '', in_state) all_table += 'border: ' + (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) + ' 2px solid;' elif re.search("^table ?bgcolor=([^=]+)$", in_state): table_data = re.sub('^table ?bgcolor=', '', in_state) all_table += 'background: ' + (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) + ';' elif re.search("^table ?color=([^=]+)$", in_state): table_data = re.sub('^table ?color=', '', in_state) all_table += 'color: ' + (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) + ';' elif re.search("^col ?bgcolor=([^=]+)$", in_state): table_data = re.sub('^col ?bgcolor=', '', in_state) table_data = (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) cel_color[cel_num] += 'background: ' + table_data + ';' cel_style += 'background: ' + table_data + ';' elif re.search("^col ?color=([^=]+)$", in_state): table_data = re.sub('^col ?color=', '', in_state) table_data = (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) cel_color[cel_num] += 'color: ' + table_data + ';' cel_style += 'color: ' + table_data + ';' elif re.search("^(bgcolor=([^=]+)|#(?:[0-9a-f-A-F]{3}){1,2}|\w+)$", in_state): table_data = re.sub('^bgcolor=', '', in_state) cel_style += 'background: ' + (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) + ';' elif re.search("^color=([^=]+)$", in_state): table_data = re.sub('^color=', '', in_state) cel_style += 'color: ' + (re.sub(',([^,]*)', '', table_data) if re.search(',', table_data) else table_data) + ';' elif re.search("^width=([^=]+)$", in_state): table_data = re.sub('^width=', '', in_state) cel_style += 'width: ' + ((table_data + 'px') if re.search('^[0-9]+$', table_data) else table_data) + ';' elif re.search("^height=([^=]+)$", in_state): table_data = re.sub('^height=', '', in_state) cel_style += 'height: ' + ((table_data + 'px') if re.search('^[0-9]+$', table_data) else table_data) + ';' elif re.search('^\(|:|\)$', in_state): if in_state == '(': cel_style += 'text-align: right;' elif in_state == ':': cel_style += 'text-align: center;' else: cel_style += 'text-align: left;' elif re.search("^table ?class=([^=]+)$", in_state): table_class += re.sub("^table ?class=", '', in_state) div_style += '"' all_table += '"' cel_style += '"' row_style += '"' table_class += '"' return [all_table, row_style, cel_style, row, cel, table_class, num, div_style, cel_color] def table_start(data): while 1: cel_num = 0 table_num = 0 table_end = '' cel_color = {} table = re.search('\n((?:(?:(?:(?:\|\||\|[^|]+\|)+(?:(?:(?!\|\|).\n*)*))+)\|\|(?:\n)?)+)', data) if table: table = '\n' + re.sub('(\|\|)+\n', '||\n', table.groups()[0]) table_cel = re.findall('(\n(?:(?:\|\|)+)|\|\|\n(?:(?:\|\|)+)|(?:(?:\|\|)+))((?:(?:(?!\n|\|\|).)+\n*)+)', table) for i in table_cel: cel_plus = re.search('^((?:<(?:(?:(?!>).)*)>)+)', i[1]) cel_plus = cel_plus.groups()[0] if cel_plus else '' cel_data = re.sub('^((?:<(?:(?:(?!>).)*)>)+)', '', i[1]) if re.search('^\n', i[0]): cel_num = 1 cel_plus = table_parser( cel_plus, cel_data, cel_num, re.sub('^\n', '', i[0]), table_num, cel_color ) cel_color = cel_plus[8] table_num = cel_plus[6] table_end += '' + \ '
' + \ '' + \ '' + \ '' + \ '' + \ '' + \ '' + \ '
' + \ cel_data elif re.search('\n', i[0]): cel_num = 1 cel_plus = table_parser( cel_plus, cel_data, cel_num, re.sub('^\|\|\n', '', i[0]), table_num, cel_color ) cel_color = cel_plus[8] table_end += '' + \ '
' + \ cel_data else: cel_num += 1 cel_plus = table_parser( cel_plus, cel_data, cel_num, re.sub('^\|\|\n', '', i[0]), table_num, cel_color ) cel_color = cel_plus[8] table_end += '' + \ '' + \ cel_data table_end += '
' data = re.sub('\n((?:(?:(?:(?:\|\||\|[^|]+\|)+(?:(?:(?!\|\|).\n*)*))+)\|\|(?:\n)?)+)', '\n' + table_end + '\n', data, 1) else: break return data def middle_parser(data, include_num): global end_data global plus_data global nowiki_num middle_stack = 0 middle_list = [] middle_num = 0 html_num = 0 syntax_num = 0 folding_num = 0 middle_re = re.compile('(?:{{{((?:(?:(?! |{{{|}}}|<).)*) ?)|(}}}))') middle_all_data = middle_re.findall(data) for middle_data in middle_all_data: if not middle_data[1]: if middle_stack > 0: middle_stack += 1 data = re.sub('(?:{{{((?:(?! |{{{|}}}|<).)*)(?P ?)|(}}}))', '' + middle_data[0] + '\g', data, 1) else: if re.search('^(#|@|\+|\-)', middle_data[0]) and not re.search('^(#|@|\+|\-){2}|(#|@|\+|\-)\\\\', middle_data[0]): if re.search('^(#(?:[0-9a-f-A-F]{3}){1,2})', middle_data[0]): middle_search = re.search('^(#(?:[0-9a-f-A-F]{3}){1,2})', middle_data[0]) middle_list += ['span'] data = middle_re.sub('', data, 1) elif re.search('^(?:#(\w+))', middle_data[0]): middle_search = re.search('^(?:#(\w+))', middle_data[0]) middle_list += ['span'] data = middle_re.sub('', data, 1) elif re.search('^(?:@((?:[0-9a-f-A-F]{3}){1,2}))', middle_data[0]): middle_search = re.search('^(?:@((?:[0-9a-f-A-F]{3}){1,2}))', middle_data[0]) middle_list += ['span'] data = middle_re.sub('', data, 1) elif re.search('^(?:@(\w+))', middle_data[0]): middle_search = re.search('^(?:@(\w+))', middle_data[0]) middle_list += ['span'] data = middle_re.sub('', data, 1) elif re.search('^(\+|-)([1-5])', middle_data[0]): middle_search = re.search('^(\+|-)([1-5])', middle_data[0]) middle_search = middle_search.groups() if middle_search[0] == '+': font_size = str(int(middle_search[1]) * 20 + 100) else: font_size = str(100 - int(middle_search[1]) * 10) middle_list += ['span'] data = middle_re.sub('', data, 1) elif re.search('^#!wiki', middle_data[0]): middle_data_2 = re.search('{{{#!wiki(?: style=(?:"|')((?:(?!"|').)*)(?:"|'))?(?: *)\n?', data) if middle_data_2: middle_data_2 = middle_data_2.groups() else: middle_data_2 = [''] middle_list += ['div_1'] data = re.sub( '{{{#!wiki(?: style=(?:"|')((?:(?!"|').)*)(?:"|'))?(?: *)\n?', '
', data, 1 ) elif re.search('^#!syntax', middle_data[0]): middle_data_2 = re.search('{{{#!syntax ((?:(?!\n).)+)\n?', data) if middle_data_2: middle_data_2 = middle_data_2.groups() else: middle_data_2 = ['python'] if syntax_num == 0: plus_data += 'hljs.initHighlightingOnLoad();\n' syntax_num = 1 middle_list += ['pre'] data = re.sub( '{{{#!syntax ?((?:(?!\n).)*)\n?', '
',
                            data,
                            1
                        )
                    elif re.search('^#!folding', middle_data[0]):
                        middle_list += ['2div']

                        folding_data = re.search('{{{#!folding ?((?:(?!\n).)*)\n?', data)
                        if folding_data:
                            folding_data = folding_data.groups()
                        else:
                            folding_data = ['Test']

                        data = re.sub(
                            '{{{#!folding ?((?:(?!\n).)*)\n?', '' + \
                            '
' + \ str(folding_data[0]) + ' ' + \ '
' + \ '' + \ '[+]' + \ '' + \ '' + \ '
', data, 1) else: data = middle_re.sub('', data, 1) del(middle_list[middle_num]) while 1: if middle_stack == 0: break else: if middle_list == []: data += '' else: if middle_stack > 0: middle_stack -= 1 if middle_stack > 0: data += '' else: if middle_num > 0: middle_num -= 1 if middle_list[middle_num] == '2div': data += '' elif middle_list[middle_num] == 'pre': data += '' else: data += '' del(middle_list[middle_num]) data = data.replace('', '{{{') data = data.replace('', '}}}') while 1: nowiki_data = re.search('((?:(?:(?!<\/code>).)*\n*)*)<\/code>', data) if nowiki_data: nowiki_data = nowiki_data.groups() nowiki_num += 1 end_data['nowiki_' + str(nowiki_num)] = nowiki_data[0] plus_data += 'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(nowiki_data[0]) + '";\n' data = re.sub( '((?:(?:(?!<\/code>).)*\n*)*)<\/code>', '', data, 1 ) else: break while 1: syntax_data = re.search('|<).)+)">((?:\n*(?:(?:(?!<\/code>||<).)+)">((?:\n*(?:(?:(?!<\/code>|', data, 1 ) else: break return data def namumark(conn, data, title, main_num, include_num): curs = conn.cursor() global plus_data global end_data global nowiki_num nowiki_num = 0 data = '\n' + data + '\n' include_num = include_num + '_' if include_num else '' plus_data = 'get_link_state("' + include_num + '");\nget_file_state("' + include_num + '");\n' backlink = [] end_data = {} data = re.sub('(?P(?:(?!<\/math>).)+)<\/math>', '[math(\g)]', data) data = html.escape(data) data = re.sub('\r\n', '\n', data) math_re = re.compile('\[math\(((?:(?!\)\]).)+)\)\]', re.I) while 1: math = math_re.search(data) if math: math = math.groups()[0] math = math.replace('{', '') math = math.replace('}', '') math = math.replace('\\', '') data = math_re.sub('' + math + '', data, 1) else: break data = data.replace('\\{', '') data = middle_parser(data, include_num) data = data.replace('', '\\{') first = 0 math_re = re.compile('((?:(?!<\/math>).)+)<\/math>', re.I) while 1: math = math_re.search(data) if math: math = math.groups()[0] math = math.replace('', '{') math = math.replace('', '}') math = math.replace('', '\\') first += 1 data = math_re.sub('', data, 1) plus_data += '' + \ 'try {' + \ 'katex.render(' + \ '"' + nowiki_js(html.unescape(math)) + '",' + \ 'document.getElementById(\"math_' + str(first) + '\")' + \ ');' + \ '} catch {' + \ 'document.getElementById(\"math_' + str(first) + '\").innerHTML = "' + nowiki_js(math) + '";' + \ '}\n' + \ '' else: break num = 0 while 1: one_nowiki = re.search('(?:\\\\)(.)', data) if one_nowiki: one_nowiki = one_nowiki.groups() nowiki_num += 1 end_data['nowiki_' + str(nowiki_num)] = one_nowiki[0] plus_data += 'document.getElementById("nowiki_' + str(nowiki_num) + '").innerHTML = "' + nowiki_js(one_nowiki[0]) + '";\n' data = re.sub('(?:\\\\)(.)', '', data, 1) else: break include_re = re.compile('\[include\(((?:(?!\)\]).)+)\)\]', re.I) i = 0 while 1: i += 1 include = include_re.search(data) if include: include = include.groups()[0] include_data = re.search('^((?:(?!,).)+)', include) if include_data: include_data = include_data.groups()[0] else: include_data = 'Test' include_link = include_data backlink += [[title, include_link, 'include']] data = include_re.sub('' + \ '[' + include_link + ']' + \ '
' + \ '', data, 1) include_plus_data = [] while 1: include_plus = re.search(', ?((?:(?!=).)+)=((?:(?!,).)+)', include) if include_plus: include_plus = include_plus.groups() include_data_set = include_plus[1] find_data = re.findall('', include_data_set) for j in find_data: include_data_set = include_data_set.replace('', end_data[j]) include_plus_data += [[include_plus[0], include_data_set]] include = re.sub(', ?((?:(?!=).)+)=((?:(?!,).)+)', '', include, 1) else: break plus_data += 'load_include("' + include_link + '", "include_' + str(i) + '", ' + str(include_plus_data) + ');\n' else: break data = re.sub('\r\n', '\n', data) data = re.sub('&', '&', data) data = re.sub('\n( +)\|\|', '\n||', data) data = re.sub('\|\|( +)\n', '||\n', data) data = re.sub('\n##(((?!\n).)+)', '', data) data = re.sub('
\n', '
', data) while 1: wiki_table_data = re.search('
).)+)>((?:(?!
).\n*)+)<\/div_1>', data) if wiki_table_data: wiki_table_data = wiki_table_data.groups() if re.search('\|\|', wiki_table_data[1]): end_parser = re.sub('\n$', '', re.sub('^\n', '', table_start('\n' + wiki_table_data[1] + '\n'))) else: end_parser = wiki_table_data[1] data = re.sub('
).)+)>((?:(?!
).\n*)+)<\/div_1>', '
' + end_parser + '', data, 1) else: break data = re.sub('<\/div_2>', '
', data) data = re.sub('<\/td>', '', data) data += '\n' data = data.replace('\\', '\') redirect_re = re.compile('\n#(?:redirect|넘겨주기) ((?:(?!\n).)+)\n', re.I) redirect = redirect_re.search(data) if redirect: redirect = redirect.groups()[0] return_link = link_fix(redirect) main_link = html.unescape(return_link[0]) other_link = return_link[1] backlink += [[title, main_link + other_link, 'redirect']] data = redirect_re.sub( '\n' + \ '' + \ '\n', data, 1 ) no_toc_re = re.compile('\[(?:목차|toc)\((?:no)\)\]\n', re.I) toc_re = re.compile('\[(?:목차|toc)\]', re.I) if not no_toc_re.search(data): if not toc_re.search(data): data = re.sub('\n(?P={1,6}) ?(?P(?:(?!=).)+) ?={1,6}\n', '\n[toc]\n\g \g \g\n', data, 1) else: data = no_toc_re.sub('', data) data = '
' + data toc_full = 0 toc_top_stack = 6 toc_stack = [0, 0, 0, 0, 0, 0] edit_number = 0 toc_data = '
TOC\n\n' while 1: toc = re.search('\n(={1,6}) ?((?:(?!\n).)+) ?(?:={1,6})\n', data) if toc: toc = toc.groups() toc_number = len(toc[0]) edit_number += 1 if toc_full > toc_number: for i in range(toc_number, 6): toc_stack[i] = 0 if toc_top_stack > toc_number: toc_top_stack = toc_number toc_full = toc_number toc_stack[toc_number - 1] += 1 toc_number = str(toc_number) all_stack = '' for i in range(0, 6): all_stack += str(toc_stack[i]) + '.' while 1: if re.search('[^0-9]0\.', all_stack): all_stack = re.sub('[^0-9]0\.', '.', all_stack) else: break all_stack = re.sub('^0\.', '', all_stack) all_stack = re.sub('\.$', '', all_stack) new_toc_data = re.sub('=*$', '', toc[1]) new_toc_data = re.sub(' +$', '', new_toc_data) if re.search('^# ?(?P[^#]+) ?#$', new_toc_data): fol_head = '+' new_toc_data = re.sub('^# ?(?P[^#]+) ?#$', '\g', new_toc_data) else: fol_head = '-' data = re.sub( '\n(={1,6}) ?((?:(?!\n).)+) ?\n', '\n' + \ '
' '' + \ '' + all_stack + '. ' + new_toc_data + ' ' + \ '' + \ '(Edit)' + \ ' ' + \ '' + \ '[' + fol_head + ']' + \ '' + \ '' + \ '' + \ '' data = toc_re.sub(toc_data, data) data = tool.savemark(data) data = re.sub("\[anchor\((?P(?:(?!\)\]).)+)\)\]", '', data, flags = re.I) ruby_all = re.findall("\[ruby\(((?:(?:(?!\)\]).)+))\)\]", data, flags = re.I) for i in ruby_all: ruby_code = re.search('^([^,]+)', i) if ruby_code: ruby_code = ruby_code.groups()[0] else: ruby_code = 'Test' ruby_top = re.search('ruby=([^,]+)', i, flags = re.I) if ruby_top: ruby_top = ruby_top.groups()[0] else: ruby_top = 'Test' ruby_color = re.search('color=([^,]+)', i, flags = re.I) if ruby_color: ruby_color = 'color: ' + ruby_color.groups()[0] + ';' else: ruby_color = '' ruby_data = '' + \ '' + \ ruby_code \ + '(' + \ '' + ruby_top + '' + \ ')' + \ '' + \ '' data = re.sub("\[ruby\(((?:(?:(?!\)\]).)+))\)\]", ruby_data, data, 1, flags = re.I) curs.execute(tool.db_change('select data from other where name = "count_all_title"')) all_title = curs.fetchall() data = re.sub('\[pagecount\]', all_title[0][0], data, flags = re.I) now_time = tool.get_time() data = re.sub('\[date\]', now_time, data, flags = re.I) time_data = re.search('^([0-9]{4}-[0-9]{2}-[0-9]{2})', now_time) time = time_data.groups() age_re = re.compile('\[age\(([0-9]{4}-[0-9]{2}-[0-9]{2})\)\]', re.I) while 1: age_data = age_re.search(data) if age_data: age = age_data.groups()[0] try: old = datetime.datetime.strptime(time[0], '%Y-%m-%d') will = datetime.datetime.strptime(age, '%Y-%m-%d') e_data = old - will data = age_re.sub(str(int(e_data.days / 365)), data, 1) except: data = age_re.sub('age-error', data, 1) else: break dday_re = re.compile('\[dday\(([0-9]{4}-[0-9]{2}-[0-9]{2})\)\]', re.I) while 1: dday_data = dday_re.search(data) if dday_data: dday = dday_data.groups()[0] try: old = datetime.datetime.strptime(time[0], '%Y-%m-%d') will = datetime.datetime.strptime(dday, '%Y-%m-%d') e_data = old - will if re.search('^-', str(e_data.days)): e_day = str(e_data.days) else: e_day = '+' + str(e_data.days) data = dday_re.sub(e_day, data, 1) except: data = dday_re.sub('dday-error', data, 1) else: break video_re = re.compile('\[(youtube|kakaotv|nicovideo)\(((?:(?!\)\]).)+)\)\]', re.I) youtube_re = re.compile('youtube', re.I) kakaotv_re = re.compile('kakaotv', re.I) while 1: video = video_re.search(data) if video: video = video.groups() width = re.search(', ?width=((?:(?!,).)+)', video[1]) if width: video_width = width.groups()[0] if re.search('^[0-9]+$', video_width): video_width += 'px' else: video_width = '560px' height = re.search(', ?height=((?:(?!,).)+)', video[1]) if height: video_height = height.groups()[0] if re.search('^[0-9]+$', video_height): video_height += 'px' else: video_height = '315px' code = re.search('^((?:(?!,).)+)', video[1]) if code: video_code = code.groups()[0] else: video_code = '' video_start = '' if youtube_re.search(video[0]): start = re.search(', ?(start=(?:(?!,).)+)', video[1]) if start: video_start = '?' + start.groups()[0] video_code = re.sub('^https:\/\/www\.youtube\.com\/watch\?v=', '', video_code) video_code = re.sub('^https:\/\/youtu\.be\/', '', video_code) video_src = 'https://www.youtube.com/embed/' + video_code elif kakaotv_re.search(video[0]): video_code = re.sub('^https:\/\/tv\.kakao\.com\/channel\/9262\/cliplink\/', '', video_code) video_code = re.sub('^http:\/\/tv\.kakao\.com\/v\/', '', video_code) video_src = 'https://tv.kakao.com/embed/player/cliplink/' + video_code +'?service=kakao_tv' else: video_src = 'https://embed.nicovideo.jp/watch/' + video_code data = video_re.sub( '', data, 1 ) else: break while 1: block = re.search('(\n(?:> ?(?:(?:(?!\n).)+)?\n)+)', data) if block: block = block.groups()[0] block = re.sub('^\n> ?', '', block) block = re.sub('\n> ?', '\n', block) block = re.sub('\n$', '', block) data = re.sub('(\n(?:> ?(?:(?:(?!\n).)+)?\n)+)', '\n
' + block + '
\n', data, 1) else: break while 1: hr = re.search('\n-{4,9}\n', data) if hr: data = re.sub('\n-{4,9}\n', '\n
\n', data, 1) else: break data = re.sub('(?P\n +\* ?(?:(?:(?!\|\|).)+))\|\|', '\g\n ||', data) data = re.sub('(?P
' data += category data = re.sub('<\/td_1>', '', data) data = re.sub('<\/ul>\n?', '', data) data = re.sub('<\/pre>\n?', '', data) data = re.sub('(?P
)(\n)+', '\g', data) data = re.sub('\n\n
    ', '\n
      ', data) data = re.sub('<\/ul>\n\n', '
    ', data) data = re.sub('^(\n)+', '', data) data = re.sub('(\n)+
      ', '
        ', data) data = re.sub('(?P).)*)>)\n', '\g', data) data = re.sub('(\n)?
        (\n)?', '
        ', data) data = re.sub('<\/ul>\n\n
          ', '
        \n
          ', data) data = re.sub('<\/ul>\n
            ', '
            ', data) data = re.sub('\n<\/ul>', '
          ', data) data = re.sub('\n', '
          ', data) plus_data = 'render_html("' + include_num + 'render_contect");\n' + plus_data return [data, plus_data, backlink]