|
@@ -4,130 +4,36 @@ import datetime
|
|
|
import html
|
|
import html
|
|
|
import re
|
|
import re
|
|
|
|
|
|
|
|
-def table_parser(data, cel_data, start_data, num = 0):
|
|
|
|
|
- table_class = 'class="'
|
|
|
|
|
- div_style = 'style="'
|
|
|
|
|
- all_table = 'style="'
|
|
|
|
|
- cel_style = 'style="'
|
|
|
|
|
- row_style = 'style="'
|
|
|
|
|
- row = ''
|
|
|
|
|
- cel = ''
|
|
|
|
|
|
|
+def link_fix(main_link):
|
|
|
|
|
+ if re.search('^:', main_link):
|
|
|
|
|
+ main_link = re.sub('^:', '', main_link)
|
|
|
|
|
|
|
|
- table_width = re.search("<table ?width=((?:(?!>).)*)>", data)
|
|
|
|
|
- if table_width:
|
|
|
|
|
- if re.search('^[0-9]+$', table_width.groups()[0]):
|
|
|
|
|
- div_style += 'width: ' + table_width.groups()[0] + 'px;'
|
|
|
|
|
- else:
|
|
|
|
|
- div_style += 'width: ' + table_width.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- all_table += 'width: 100%;'
|
|
|
|
|
-
|
|
|
|
|
- table_height = re.search("<table ?height=((?:(?!>).)*)>", data)
|
|
|
|
|
- if table_height:
|
|
|
|
|
- if re.search('^[0-9]+$', table_height.groups()[0]):
|
|
|
|
|
- all_table += 'height: ' + table_height.groups()[0] + 'px;'
|
|
|
|
|
- else:
|
|
|
|
|
- all_table += 'height: ' + table_height.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- # width, height
|
|
|
|
|
-
|
|
|
|
|
- table_align = re.search("<table ?align=((?:(?!>).)*)>", data)
|
|
|
|
|
- if table_align:
|
|
|
|
|
- if table_align.groups()[0] == 'right':
|
|
|
|
|
- all_table += 'float: right;'
|
|
|
|
|
- elif table_align.groups()[0] == 'center':
|
|
|
|
|
- all_table += 'margin: auto;'
|
|
|
|
|
-
|
|
|
|
|
- table_text_align = re.search("<table ?textalign=((?:(?!>).)*)>", data)
|
|
|
|
|
- if table_text_align:
|
|
|
|
|
- num = 1
|
|
|
|
|
-
|
|
|
|
|
- if table_text_align.groups()[0] == 'right':
|
|
|
|
|
- all_table += 'text-align: right;'
|
|
|
|
|
- elif table_text_align.groups()[0] == 'center':
|
|
|
|
|
- all_table += 'text-align: center;'
|
|
|
|
|
-
|
|
|
|
|
- row_table_align = re.search("<row ?textalign=((?:(?!>).)*)>", data)
|
|
|
|
|
- if row_table_align:
|
|
|
|
|
- if row_table_align.groups()[0] == 'right':
|
|
|
|
|
- row_style += 'text-align: right;'
|
|
|
|
|
- elif row_table_align.groups()[0] == 'center':
|
|
|
|
|
- row_style += 'text-align: center;'
|
|
|
|
|
- else:
|
|
|
|
|
- row_style += 'text-align: left;'
|
|
|
|
|
|
|
+ main_link = re.sub('^사용자:', 'user:', main_link)
|
|
|
|
|
+ main_link = re.sub('^파일:', 'file:', main_link)
|
|
|
|
|
+ main_link = re.sub('^분류:', 'category:', main_link)
|
|
|
|
|
|
|
|
- # align
|
|
|
|
|
|
|
+ other_link = re.search('[^\\\\]?(#[^#]+)$', main_link)
|
|
|
|
|
+ if other_link:
|
|
|
|
|
+ other_link = other_link.groups()[0]
|
|
|
|
|
|
|
|
- table_cel = re.search("<-((?:(?!>).)*)>", data)
|
|
|
|
|
- if table_cel:
|
|
|
|
|
- cel = 'colspan="' + table_cel.groups()[0] + '"'
|
|
|
|
|
|
|
+ main_link = re.sub('(#[^#]+)$', '', main_link)
|
|
|
else:
|
|
else:
|
|
|
- cel = 'colspan="' + str(round(len(start_data) / 2)) + '"'
|
|
|
|
|
-
|
|
|
|
|
- table_row = re.search("<\|((?:(?!>).)*)>", data)
|
|
|
|
|
- if table_row:
|
|
|
|
|
- row = 'rowspan="' + table_row.groups()[0] + '"'
|
|
|
|
|
|
|
+ other_link = ''
|
|
|
|
|
|
|
|
- # <>
|
|
|
|
|
|
|
+ main_link = re.sub('\\\\#', '%23', main_link)
|
|
|
|
|
|
|
|
- row_bgcolor = re.search("<rowbgcolor=(#(?:[0-9a-f-A-F]{3}){1,2}|\w+)>", data)
|
|
|
|
|
- if row_bgcolor:
|
|
|
|
|
- row_style += 'background: ' + row_bgcolor.groups()[0] + ';'
|
|
|
|
|
|
|
+ return [main_link, other_link]
|
|
|
|
|
|
|
|
- row_bgcolor = re.search("<rowcolor=(#(?:[0-9a-f-A-F]{3}){1,2}|\w+)>", data)
|
|
|
|
|
- if row_bgcolor:
|
|
|
|
|
- row_style += 'color: ' + row_bgcolor.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- # row
|
|
|
|
|
-
|
|
|
|
|
- table_border = re.search("<table ?bordercolor=(#(?:[0-9a-f-A-F]{3}){1,2}|\w+)>", data)
|
|
|
|
|
- if table_border:
|
|
|
|
|
- all_table += 'border: ' + table_border.groups()[0] + ' 2px solid;'
|
|
|
|
|
-
|
|
|
|
|
- table_bgcolor = re.search("<table ?bgcolor=(#(?:[0-9a-f-A-F]{3}){1,2}|\w+)>", data)
|
|
|
|
|
- if table_bgcolor:
|
|
|
|
|
- all_table += 'background: ' + table_bgcolor.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- table_bgcolor = re.search("<table ?color=(#(?:[0-9a-f-A-F]{3}){1,2}|\w+)>", data)
|
|
|
|
|
- if table_bgcolor:
|
|
|
|
|
- all_table += 'color: ' + table_bgcolor.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- # all
|
|
|
|
|
-
|
|
|
|
|
- bgcolor = re.search("<(?:bgcolor=)?(#(?:[0-9a-f-A-F]{3}){1,2}|\w+)>", data)
|
|
|
|
|
- if bgcolor:
|
|
|
|
|
- cel_style += 'background: ' + bgcolor.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- bgcolor = re.search("<color=(#(?:[0-9a-f-A-F]{3}){1,2}|\w+)>", data)
|
|
|
|
|
- if bgcolor:
|
|
|
|
|
- cel_style += 'color: ' + bgcolor.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- cel_width = re.search("<width=((?:(?!>).)*)>", data)
|
|
|
|
|
- if cel_width:
|
|
|
|
|
- if re.search('^[0-9]+$', cel_width.groups()[0]):
|
|
|
|
|
- cel_style += 'width: ' + cel_width.groups()[0] + 'px;'
|
|
|
|
|
- else:
|
|
|
|
|
- cel_style += 'width: ' + cel_width.groups()[0] + ';'
|
|
|
|
|
|
|
+def table_parser(data, cel_data, start_data, num = 0):
|
|
|
|
|
+ table_class = 'class="'
|
|
|
|
|
+ div_style = 'style="'
|
|
|
|
|
+ all_table = 'style="'
|
|
|
|
|
+ cel_style = 'style="'
|
|
|
|
|
+ row_style = 'style="'
|
|
|
|
|
+ row = ''
|
|
|
|
|
+ cel = 'colspan="' + str(round(len(start_data) / 2)) + '"'
|
|
|
|
|
|
|
|
- cel_height = re.search("<height=((?:(?!>).)*)>", data)
|
|
|
|
|
- if cel_height:
|
|
|
|
|
- if re.search('^[0-9]+$', cel_height.groups()[0]):
|
|
|
|
|
- cel_style += 'height: ' + cel_height.groups()[0] + 'px;'
|
|
|
|
|
- else:
|
|
|
|
|
- cel_style += 'height: ' + cel_height.groups()[0] + ';'
|
|
|
|
|
-
|
|
|
|
|
- # cel
|
|
|
|
|
-
|
|
|
|
|
- text_right = re.search("<\)>", data)
|
|
|
|
|
- text_center = re.search("<:>", data)
|
|
|
|
|
- text_left = re.search("<\(>", data)
|
|
|
|
|
- if text_right:
|
|
|
|
|
- cel_style += 'text-align: right;'
|
|
|
|
|
- elif text_center:
|
|
|
|
|
- cel_style += 'text-align: center;'
|
|
|
|
|
- elif text_left:
|
|
|
|
|
- cel_style += 'text-align: left;'
|
|
|
|
|
- elif num == 0:
|
|
|
|
|
|
|
+ if num == 0:
|
|
|
if re.search('^ ', cel_data) and re.search(' $', cel_data):
|
|
if re.search('^ ', cel_data) and re.search(' $', cel_data):
|
|
|
cel_style += 'text-align: center;'
|
|
cel_style += 'text-align: center;'
|
|
|
elif re.search('^ ', cel_data):
|
|
elif re.search('^ ', cel_data):
|
|
@@ -135,9 +41,80 @@ def table_parser(data, cel_data, start_data, num = 0):
|
|
|
elif re.search(' $', cel_data):
|
|
elif re.search(' $', cel_data):
|
|
|
cel_style += 'text-align: left;'
|
|
cel_style += 'text-align: left;'
|
|
|
|
|
|
|
|
- text_class = re.search("<table ?class=((?:(?!>).)+)>", data)
|
|
|
|
|
- if text_class:
|
|
|
|
|
- table_class += text_class.groups()[0]
|
|
|
|
|
|
|
+ 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("^(bgcolor=([^=]+)|#(?:[0-9a-f-A-F]{3}){1,2}|\w+)$", in_state):
|
|
|
|
|
+ cel_style += 'background: ' + re.sub('^bgcolor=', '', in_state) + ';'
|
|
|
|
|
+ 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 += '"'
|
|
div_style += '"'
|
|
|
all_table += '"'
|
|
all_table += '"'
|
|
@@ -149,30 +126,32 @@ def table_parser(data, cel_data, start_data, num = 0):
|
|
|
|
|
|
|
|
def table_start(data):
|
|
def table_start(data):
|
|
|
while 1:
|
|
while 1:
|
|
|
- table = re.search('\n((?:(?:(?:(?:\|\|)+(?:(?:(?!\|\|).(?:\n)*)*))+)\|\|(?:\n)?)+)', data)
|
|
|
|
|
|
|
+ table = re.search('\n((?:(?:(?:(?:\|\||\|[^|]+\|)+(?:(?:(?!\|\|).\n*)*))+)\|\|(?:\n)?)+)', data)
|
|
|
if table:
|
|
if table:
|
|
|
table = table.groups()[0]
|
|
table = table.groups()[0]
|
|
|
- while 1:
|
|
|
|
|
- all_table = re.search('^((?:\|\|)+)((?:<(?:(?:(?!>).)+)>)*)\n*((?:(?!\|\|).\n*)*)', table)
|
|
|
|
|
- if all_table:
|
|
|
|
|
- all_table = all_table.groups()
|
|
|
|
|
|
|
|
|
|
- return_table = table_parser(all_table[1], all_table[2], all_table[0])
|
|
|
|
|
- number = return_table[6]
|
|
|
|
|
-
|
|
|
|
|
- table = re.sub(
|
|
|
|
|
- '^((?:\|\|)+)((?:<(?:(?:(?!>).)+)>)*)\n*',
|
|
|
|
|
- '\n' + \
|
|
|
|
|
- '<div class="table_safe" ' + return_table[7] + '>' + \
|
|
|
|
|
- '<table ' + return_table[5] + ' ' + return_table[0] + '>' + \
|
|
|
|
|
- '<tbody>' + \
|
|
|
|
|
- '<tr ' + return_table[1] + '>' + \
|
|
|
|
|
- '<td ' + return_table[2] + ' ' + return_table[3] + ' ' + return_table[4] + '>',
|
|
|
|
|
- table,
|
|
|
|
|
- 1
|
|
|
|
|
- )
|
|
|
|
|
- else:
|
|
|
|
|
- break
|
|
|
|
|
|
|
+ all_table = re.search('^((?:\|\||\|[^|]+\|)+)((?:<(?:(?:(?!>).)+)>)*)\n*((?:(?!\|\|).\n*)*)', table)
|
|
|
|
|
+ if all_table:
|
|
|
|
|
+ all_table = all_table.groups()
|
|
|
|
|
+
|
|
|
|
|
+ return_table = table_parser(all_table[1], all_table[2], re.sub('^\|([^|]+)\|', '||', all_table[0]))
|
|
|
|
|
+ number = return_table[6]
|
|
|
|
|
+
|
|
|
|
|
+ table_caption = re.search('^\|([^|]+)\|', table)
|
|
|
|
|
+ table_caption = '<caption>' + table_caption.groups()[0] + '</caption>' if table_caption else ''
|
|
|
|
|
+
|
|
|
|
|
+ table = re.sub(
|
|
|
|
|
+ '^((?:\|\||\|[^|]+\|)+)((?:<(?:(?:(?!>).)+)>)*)\n*',
|
|
|
|
|
+ '\n' + \
|
|
|
|
|
+ '<div class="table_safe" ' + return_table[7] + '>' + \
|
|
|
|
|
+ '<table ' + return_table[5] + ' ' + return_table[0] + '>' + \
|
|
|
|
|
+ table_caption + \
|
|
|
|
|
+ '<tbody>' + \
|
|
|
|
|
+ '<tr ' + return_table[1] + '>' + \
|
|
|
|
|
+ '<td ' + return_table[2] + ' ' + return_table[3] + ' ' + return_table[4] + '>',
|
|
|
|
|
+ table,
|
|
|
|
|
+ 1
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
table = re.sub('\|\|\n?$', '</td></tr></tbody></table></div>', table)
|
|
table = re.sub('\|\|\n?$', '</td></tr></tbody></table></div>', table)
|
|
|
|
|
|
|
@@ -208,20 +187,23 @@ def table_start(data):
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
- data = re.sub('\n((?:(?:(?:(?:\|\|)+(?:(?:(?!\|\|).(?:\n)*)*))+)\|\|(?:\n)?)+)', table, data, 1)
|
|
|
|
|
|
|
+ data = re.sub('\n((?:(?:(?:(?:\|\||\|[^|]+\|)+(?:(?:(?!\|\|).\n*)*))+)\|\|(?:\n)?)+)', table, data, 1)
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
return data
|
|
return data
|
|
|
|
|
|
|
|
-def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
|
|
|
|
+def middle_parser(data, include_num):
|
|
|
global end_data
|
|
global end_data
|
|
|
global plus_data
|
|
global plus_data
|
|
|
|
|
|
|
|
middle_stack = 0
|
|
middle_stack = 0
|
|
|
middle_list = []
|
|
middle_list = []
|
|
|
- middle_number = 0
|
|
|
|
|
- html_number = 0
|
|
|
|
|
|
|
+ middle_num = 0
|
|
|
|
|
+
|
|
|
|
|
+ html_num = 0
|
|
|
|
|
+ syntax_num = 0
|
|
|
|
|
+ folding_num = 0
|
|
|
|
|
|
|
|
middle_re = re.compile('(?:{{{((?:(?:(?! |{{{|}}}|<).)*) ?)|(}}}))')
|
|
middle_re = re.compile('(?:{{{((?:(?:(?! |{{{|}}}|<).)*) ?)|(}}}))')
|
|
|
middle_all_data = middle_re.findall(data)
|
|
middle_all_data = middle_re.findall(data)
|
|
@@ -287,7 +269,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
middle_data_2 = ['python']
|
|
middle_data_2 = ['python']
|
|
|
|
|
|
|
|
if syntax_num == 0:
|
|
if syntax_num == 0:
|
|
|
- plus_data += '<script>hljs.initHighlightingOnLoad();</script>'
|
|
|
|
|
|
|
+ plus_data += 'hljs.initHighlightingOnLoad();\n'
|
|
|
|
|
|
|
|
syntax_num = 1
|
|
syntax_num = 1
|
|
|
|
|
|
|
@@ -308,31 +290,28 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
else:
|
|
else:
|
|
|
folding_data = ['Test']
|
|
folding_data = ['Test']
|
|
|
|
|
|
|
|
- if folding_num == 0:
|
|
|
|
|
- folding_num = 1
|
|
|
|
|
-
|
|
|
|
|
data = re.sub(
|
|
data = re.sub(
|
|
|
'{{{#!folding ?((?:(?!\n).)*)\n?', '' + \
|
|
'{{{#!folding ?((?:(?!\n).)*)\n?', '' + \
|
|
|
'<div>' + \
|
|
'<div>' + \
|
|
|
str(folding_data[0]) + ' ' + \
|
|
str(folding_data[0]) + ' ' + \
|
|
|
'<div style="display: inline-block;">' + \
|
|
'<div style="display: inline-block;">' + \
|
|
|
- '<a href="javascript:void(0);" onclick="do_open_folding(\'' + include_num + 'folding_' + str(fol_num) + '\', this);">' + \
|
|
|
|
|
|
|
+ '<a href="javascript:void(0);" onclick="do_open_folding(\'' + include_num + 'folding_' + str(folding_num) + '\', this);">' + \
|
|
|
'[+]' + \
|
|
'[+]' + \
|
|
|
'</a>' + \
|
|
'</a>' + \
|
|
|
'</div_2>' + \
|
|
'</div_2>' + \
|
|
|
- '<div id="' + include_num + 'folding_' + str(fol_num) + '" style="display: none;">' + \
|
|
|
|
|
|
|
+ '<div id="' + include_num + 'folding_' + str(folding_num) + '" style="display: none;">' + \
|
|
|
'<div id="wiki_div" style="">',
|
|
'<div id="wiki_div" style="">',
|
|
|
data,
|
|
data,
|
|
|
1
|
|
1
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- fol_num += 1
|
|
|
|
|
|
|
+ folding_num += 1
|
|
|
elif re.search('^#!html', middle_data[0]):
|
|
elif re.search('^#!html', middle_data[0]):
|
|
|
middle_list += ['span']
|
|
middle_list += ['span']
|
|
|
|
|
|
|
|
- html_number += 1
|
|
|
|
|
|
|
+ html_num += 1
|
|
|
|
|
|
|
|
- data = middle_re.sub('<span id="' + include_num + 'render_contect_' + str(html_number) + '">', data, 1)
|
|
|
|
|
|
|
+ data = middle_re.sub('<span id="' + include_num + 'render_contect_' + str(html_num) + '">', data, 1)
|
|
|
else:
|
|
else:
|
|
|
middle_list += ['span']
|
|
middle_list += ['span']
|
|
|
|
|
|
|
@@ -344,7 +323,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
|
|
|
|
|
data = middle_re.sub('<code>' + middle_data[0].replace('\\', '\\\\'), data, 1)
|
|
data = middle_re.sub('<code>' + middle_data[0].replace('\\', '\\\\'), data, 1)
|
|
|
|
|
|
|
|
- middle_number += 1
|
|
|
|
|
|
|
+ middle_num += 1
|
|
|
else:
|
|
else:
|
|
|
if middle_list == []:
|
|
if middle_list == []:
|
|
|
data = middle_re.sub('}}}', data, 1)
|
|
data = middle_re.sub('}}}', data, 1)
|
|
@@ -355,17 +334,17 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
if middle_stack > 0:
|
|
if middle_stack > 0:
|
|
|
data = middle_re.sub('}}}', data, 1)
|
|
data = middle_re.sub('}}}', data, 1)
|
|
|
else:
|
|
else:
|
|
|
- if middle_number > 0:
|
|
|
|
|
- middle_number -= 1
|
|
|
|
|
|
|
+ if middle_num > 0:
|
|
|
|
|
+ middle_num -= 1
|
|
|
|
|
|
|
|
- if middle_list[middle_number] == '2div':
|
|
|
|
|
|
|
+ if middle_list[middle_num] == '2div':
|
|
|
data = middle_re.sub('</div_1></div_2></div_2>', data, 1)
|
|
data = middle_re.sub('</div_1></div_2></div_2>', data, 1)
|
|
|
- elif middle_list[middle_number] == 'pre':
|
|
|
|
|
|
|
+ elif middle_list[middle_num] == 'pre':
|
|
|
data = middle_re.sub('</code></pre>', data, 1)
|
|
data = middle_re.sub('</code></pre>', data, 1)
|
|
|
else:
|
|
else:
|
|
|
- data = middle_re.sub('</' + middle_list[middle_number] + '>', data, 1)
|
|
|
|
|
|
|
+ data = middle_re.sub('</' + middle_list[middle_num] + '>', data, 1)
|
|
|
|
|
|
|
|
- del(middle_list[middle_number])
|
|
|
|
|
|
|
+ del(middle_list[middle_num])
|
|
|
|
|
|
|
|
while 1:
|
|
while 1:
|
|
|
if middle_stack == 0:
|
|
if middle_stack == 0:
|
|
@@ -380,17 +359,17 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
if middle_stack > 0:
|
|
if middle_stack > 0:
|
|
|
data += '}}}'
|
|
data += '}}}'
|
|
|
else:
|
|
else:
|
|
|
- if middle_number > 0:
|
|
|
|
|
- middle_number -= 1
|
|
|
|
|
|
|
+ if middle_num > 0:
|
|
|
|
|
+ middle_num -= 1
|
|
|
|
|
|
|
|
- if middle_list[middle_number] == '2div':
|
|
|
|
|
|
|
+ if middle_list[middle_num] == '2div':
|
|
|
data += '</div_1></div_2></div_2>'
|
|
data += '</div_1></div_2></div_2>'
|
|
|
- elif middle_list[middle_number] == 'pre':
|
|
|
|
|
|
|
+ elif middle_list[middle_num] == 'pre':
|
|
|
data += '</code></pre>'
|
|
data += '</code></pre>'
|
|
|
else:
|
|
else:
|
|
|
- data += '</' + middle_list[middle_number] + '>'
|
|
|
|
|
|
|
+ data += '</' + middle_list[middle_num] + '>'
|
|
|
|
|
|
|
|
- del(middle_list[middle_number])
|
|
|
|
|
|
|
+ del(middle_list[middle_num])
|
|
|
|
|
|
|
|
num = 0
|
|
num = 0
|
|
|
while 1:
|
|
while 1:
|
|
@@ -399,8 +378,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
nowiki_data = nowiki_data.groups()
|
|
nowiki_data = nowiki_data.groups()
|
|
|
|
|
|
|
|
num += 1
|
|
num += 1
|
|
|
-
|
|
|
|
|
- end_data += [['nowiki_' + str(num), nowiki_data[0], 'code']]
|
|
|
|
|
|
|
+ end_data['nowiki_' + str(num)] = [nowiki_data[0], 'code']
|
|
|
|
|
|
|
|
data = re.sub(
|
|
data = re.sub(
|
|
|
'<code>((?:(?:(?!<\/code>).)*\n*)*)<\/code>',
|
|
'<code>((?:(?:(?!<\/code>).)*\n*)*)<\/code>',
|
|
@@ -413,16 +391,16 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
|
|
|
|
|
num = 0
|
|
num = 0
|
|
|
while 1:
|
|
while 1:
|
|
|
- syntax_data = re.search('<code class="((?:(?!").)+)">((?:(?:(?:(?!<\/code>|<span id="syntax_)).)+\n*)+)<\/code>', data)
|
|
|
|
|
|
|
+ syntax_data = re.search('<code class="((?:(?!"|>|<).)+)">((?:\n*(?:(?:(?!<\/code>|<span id="syntax_).)+)\n*)+)<\/code>', data)
|
|
|
if syntax_data:
|
|
if syntax_data:
|
|
|
syntax_data = syntax_data.groups()
|
|
syntax_data = syntax_data.groups()
|
|
|
|
|
|
|
|
num += 1
|
|
num += 1
|
|
|
|
|
|
|
|
- end_data += [['syntax_' + str(num), syntax_data[1], 'normal']]
|
|
|
|
|
|
|
+ end_data['syntax_' + str(num)] = [syntax_data[1], 'normal']
|
|
|
|
|
|
|
|
data = re.sub(
|
|
data = re.sub(
|
|
|
- '<code class="((?:(?!").)+)">((?:(?:(?:(?!<\/code>|<span id="syntax_)).)+\n*)+)<\/code>',
|
|
|
|
|
|
|
+ '<code class="((?:(?!"|>|<).)+)">((?:\n*(?:(?:(?!<\/code>|<span id="syntax_).)+)\n*)+)<\/code>',
|
|
|
'<code class="' + syntax_data[0] + '"><span id="syntax_' + str(num) + '"></span></code>',
|
|
'<code class="' + syntax_data[0] + '"><span id="syntax_' + str(num) + '"></span></code>',
|
|
|
data,
|
|
data,
|
|
|
1
|
|
1
|
|
@@ -430,7 +408,7 @@ def middle_parser(data, fol_num, syntax_num, folding_num, include_num):
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
- return [data, [fol_num, syntax_num, folding_num]]
|
|
|
|
|
|
|
+ return data
|
|
|
|
|
|
|
|
def namumark(conn, data, title, main_num, include_num):
|
|
def namumark(conn, data, title, main_num, include_num):
|
|
|
curs = conn.cursor()
|
|
curs = conn.cursor()
|
|
@@ -439,12 +417,11 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
global end_data
|
|
global end_data
|
|
|
|
|
|
|
|
data = '\n' + data + '\n'
|
|
data = '\n' + data + '\n'
|
|
|
- plus_data = ''
|
|
|
|
|
|
|
+ include_num = include_num + '_' if include_num else ''
|
|
|
|
|
+ plus_data = 'get_link_state("' + include_num + '");\nget_file_state("' + include_num + '");\n'
|
|
|
|
|
|
|
|
backlink = []
|
|
backlink = []
|
|
|
- end_data = []
|
|
|
|
|
-
|
|
|
|
|
- include_num = include_num + '_' if include_num else ''
|
|
|
|
|
|
|
+ end_data = {}
|
|
|
|
|
|
|
|
data = re.sub('<math>(?P<in>(?:(?!<\/math>).)+)<\/math>', '[math(\g<in>)]', data)
|
|
data = re.sub('<math>(?P<in>(?:(?!<\/math>).)+)<\/math>', '[math(\g<in>)]', data)
|
|
|
|
|
|
|
@@ -463,22 +440,20 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
data = math_re.sub('<span id="math_' + str(first) + '"></span>', data, 1)
|
|
data = math_re.sub('<span id="math_' + str(first) + '"></span>', data, 1)
|
|
|
|
|
|
|
|
plus_data += '''
|
|
plus_data += '''
|
|
|
- <script>
|
|
|
|
|
- try {
|
|
|
|
|
- katex.render(
|
|
|
|
|
- "''' + html.unescape(math).replace('\\', '\\\\').replace('"', '\\"') + '''",
|
|
|
|
|
- document.getElementById("math_''' + str(first) + '''")
|
|
|
|
|
- );
|
|
|
|
|
- } catch {
|
|
|
|
|
- document.getElementById("math_''' + str(first) + '''").innerHTML = '<span style="color: red;">''' + math.replace('\\', '\\\\') + '''</span>';
|
|
|
|
|
- }
|
|
|
|
|
- </script>
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ katex.render(
|
|
|
|
|
+ "''' + html.unescape(math).replace('\\', '\\\\').replace('"', '\\"') + '''",
|
|
|
|
|
+ document.getElementById("math_''' + str(first) + '''")
|
|
|
|
|
+ );
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ document.getElementById("math_''' + str(first) + '''").innerHTML = '<span style="color: red;">''' + math.replace('\\', '\\\\') + '''</span>';
|
|
|
|
|
+ }\n
|
|
|
'''
|
|
'''
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
data = re.sub('\\\\{', '<break_middle>', data)
|
|
data = re.sub('\\\\{', '<break_middle>', data)
|
|
|
- data = middle_parser(data, 0, 0, 0, include_num)[0]
|
|
|
|
|
|
|
+ data = middle_parser(data, include_num)
|
|
|
data = re.sub('<break_middle>', '\\{', data)
|
|
data = re.sub('<break_middle>', '\\{', data)
|
|
|
|
|
|
|
|
num = 0
|
|
num = 0
|
|
@@ -489,7 +464,7 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
|
|
|
|
|
num += 1
|
|
num += 1
|
|
|
|
|
|
|
|
- end_data += [['one_nowiki_' + str(num), one_nowiki[0], 'normal']]
|
|
|
|
|
|
|
+ end_data['one_nowiki_' + str(num)] = [one_nowiki[0], 'normal']
|
|
|
|
|
|
|
|
data = re.sub('(?:\\\\)(.)', '<span id="one_nowiki_' + str(num) + '"></span>', data, 1)
|
|
data = re.sub('(?:\\\\)(.)', '<span id="one_nowiki_' + str(num) + '"></span>', data, 1)
|
|
|
else:
|
|
else:
|
|
@@ -511,29 +486,31 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
include_data = 'Test'
|
|
include_data = 'Test'
|
|
|
|
|
|
|
|
include_link = include_data
|
|
include_link = include_data
|
|
|
-
|
|
|
|
|
backlink += [[title, include_link, 'include']]
|
|
backlink += [[title, include_link, 'include']]
|
|
|
|
|
|
|
|
- curs.execute(tool.db_change("select title from data where title = ?"), [include_data])
|
|
|
|
|
- if curs.fetchall():
|
|
|
|
|
- data = include_re.sub('' + \
|
|
|
|
|
- '<a id="include_link" href="/w/' + tool.url_pas(include_link) + '">[' + include_link + ']</a><div id="include_' + str(i) + '"></div>' + \
|
|
|
|
|
- '', data, 1)
|
|
|
|
|
|
|
+ data = include_re.sub('' + \
|
|
|
|
|
+ '<a id="include_link" class="include_' + str(i) + '" href="/w/' + tool.url_pas(include_link) + '">[' + include_link + ']</a>' + \
|
|
|
|
|
+ '<div id="include_' + str(i) + '"></div>' + \
|
|
|
|
|
+ '', data, 1)
|
|
|
|
|
|
|
|
- include_plus_data = []
|
|
|
|
|
- while 1:
|
|
|
|
|
- include_plus = re.search(', ?((?:(?!=).)+)=((?:(?!,).)+)', include)
|
|
|
|
|
- if include_plus:
|
|
|
|
|
- include_plus = include_plus.groups()
|
|
|
|
|
- include_plus_data += [[include_plus[0], include_plus[1]]]
|
|
|
|
|
|
|
+ include_plus_data = []
|
|
|
|
|
+ while 1:
|
|
|
|
|
+ include_plus = re.search(', ?((?:(?!=).)+)=((?:(?!,).)+)', include)
|
|
|
|
|
+ if include_plus:
|
|
|
|
|
+ include_plus = include_plus.groups()
|
|
|
|
|
|
|
|
- include = re.sub(', ?((?:(?!=).)+)=((?:(?!,).)+)', '', include, 1)
|
|
|
|
|
- else:
|
|
|
|
|
- break
|
|
|
|
|
|
|
+ include_data_set = include_plus[1]
|
|
|
|
|
+ find_data = re.findall('<span id="(one_nowiki_[0-9]+)">', include_data_set)
|
|
|
|
|
+ for j in find_data:
|
|
|
|
|
+ include_data_set = include_data_set.replace('<span id="' + j + '"></span>', end_data[j][0])
|
|
|
|
|
|
|
|
- plus_data += '<script>load_include("' + include_link + '", "include_' + str(i) + '", ' + str(include_plus_data) + ');</script>'
|
|
|
|
|
- else:
|
|
|
|
|
- data = include_re.sub('<a id="not_thing" href="/w/' + tool.url_pas(include_link) + '">[' + include_link + ']</a>', data, 1)
|
|
|
|
|
|
|
+ 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:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
@@ -565,20 +542,12 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
data += '\n'
|
|
data += '\n'
|
|
|
data = data.replace('\\', '\')
|
|
data = data.replace('\\', '\')
|
|
|
|
|
|
|
|
- data = re.sub(''''(?P<in>((?!''').)+)'''', '<b>\g<in></b>', data)
|
|
|
|
|
- data = re.sub('''(?P<in>((?!'').)+)''', '<i>\g<in></i>', data)
|
|
|
|
|
- data = re.sub('~~(?P<in>(?:(?!~~).)+)~~', '<s>\g<in></s>', data)
|
|
|
|
|
- data = re.sub('--(?P<in>(?:(?!--).)+)--', '<s>\g<in></s>', data)
|
|
|
|
|
- data = re.sub('__(?P<in>(?:(?!__).)+)__', '<u>\g<in></u>', data)
|
|
|
|
|
- data = re.sub('\^\^(?P<in>(?:(?!\^\^).)+)\^\^', '<sup>\g<in></sup>', data)
|
|
|
|
|
- data = re.sub(',,(?P<in>(?:(?!,,).)+),,', '<sub>\g<in></sub>', data)
|
|
|
|
|
-
|
|
|
|
|
redirect_re = re.compile('\n#(?:redirect|넘겨주기) ((?:(?!\n).)+)\n', re.I)
|
|
redirect_re = re.compile('\n#(?:redirect|넘겨주기) ((?:(?!\n).)+)\n', re.I)
|
|
|
redirect = redirect_re.search(data)
|
|
redirect = redirect_re.search(data)
|
|
|
if redirect:
|
|
if redirect:
|
|
|
redirect = redirect.groups()[0]
|
|
redirect = redirect.groups()[0]
|
|
|
|
|
|
|
|
- return_link = tool.link_fix(redirect)
|
|
|
|
|
|
|
+ return_link = link_fix(redirect)
|
|
|
main_link = return_link[0]
|
|
main_link = return_link[0]
|
|
|
other_link = return_link[1]
|
|
other_link = return_link[1]
|
|
|
|
|
|
|
@@ -723,7 +692,6 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
|
|
|
|
|
data = re.sub("\[ruby\(((?:(?:(?!\)\]).)+))\)\]", ruby_data, data, 1, flags = re.I)
|
|
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"'))
|
|
curs.execute(tool.db_change('select data from other where name = "count_all_title"'))
|
|
|
all_title = curs.fetchall()
|
|
all_title = curs.fetchall()
|
|
|
data = re.sub('\[pagecount\]', all_title[0][0], data, flags = re.I)
|
|
data = re.sub('\[pagecount\]', all_title[0][0], data, flags = re.I)
|
|
@@ -740,12 +708,15 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
if age_data:
|
|
if age_data:
|
|
|
age = age_data.groups()[0]
|
|
age = age_data.groups()[0]
|
|
|
|
|
|
|
|
- old = datetime.datetime.strptime(time[0], '%Y-%m-%d')
|
|
|
|
|
- will = datetime.datetime.strptime(age, '%Y-%m-%d')
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ old = datetime.datetime.strptime(time[0], '%Y-%m-%d')
|
|
|
|
|
+ will = datetime.datetime.strptime(age, '%Y-%m-%d')
|
|
|
|
|
|
|
|
- e_data = old - will
|
|
|
|
|
|
|
+ e_data = old - will
|
|
|
|
|
|
|
|
- data = age_re.sub(str(int(e_data.days / 365)), data, 1)
|
|
|
|
|
|
|
+ data = age_re.sub(str(int(e_data.days / 365)), data, 1)
|
|
|
|
|
+ except:
|
|
|
|
|
+ data = age_re.sub('age-error', data, 1)
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
@@ -755,17 +726,20 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
if dday_data:
|
|
if dday_data:
|
|
|
dday = dday_data.groups()[0]
|
|
dday = dday_data.groups()[0]
|
|
|
|
|
|
|
|
- old = datetime.datetime.strptime(time[0], '%Y-%m-%d')
|
|
|
|
|
- will = datetime.datetime.strptime(dday, '%Y-%m-%d')
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ old = datetime.datetime.strptime(time[0], '%Y-%m-%d')
|
|
|
|
|
+ will = datetime.datetime.strptime(dday, '%Y-%m-%d')
|
|
|
|
|
|
|
|
- e_data = old - will
|
|
|
|
|
|
|
+ e_data = old - will
|
|
|
|
|
|
|
|
- if re.search('^-', str(e_data.days)):
|
|
|
|
|
- e_day = str(e_data.days)
|
|
|
|
|
- else:
|
|
|
|
|
- e_day = '+' + str(e_data.days)
|
|
|
|
|
|
|
+ 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)
|
|
|
|
|
|
|
+ data = dday_re.sub(e_day, data, 1)
|
|
|
|
|
+ except:
|
|
|
|
|
+ data = dday_re.sub('dday-error', data, 1)
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
@@ -818,7 +792,11 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
else:
|
|
else:
|
|
|
video_src = 'https://embed.nicovideo.jp/watch/' + video_code
|
|
video_src = 'https://embed.nicovideo.jp/watch/' + video_code
|
|
|
|
|
|
|
|
- data = video_re.sub('<iframe style="width: ' + video_width + '; height: ' + video_height + ';" src="' + video_src + video_start + '" allowfullscreen></iframe>', data, 1)
|
|
|
|
|
|
|
+ data = video_re.sub(
|
|
|
|
|
+ '<iframe style="width: ' + video_width + '; height: ' + video_height + ';" src="' + video_src + video_start + '" allowfullscreen></iframe>',
|
|
|
|
|
+ data,
|
|
|
|
|
+ 1
|
|
|
|
|
+ )
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
@@ -882,7 +860,7 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
|
|
|
|
|
data = table_start(data)
|
|
data = table_start(data)
|
|
|
|
|
|
|
|
- category = '<div id="cate_all"><hr><div id="cate">Category : '
|
|
|
|
|
|
|
+ category = ''
|
|
|
category_re = re.compile('^(?:category|분류):', re.I)
|
|
category_re = re.compile('^(?:category|분류):', re.I)
|
|
|
while 1:
|
|
while 1:
|
|
|
link = re.search('\[\[((?:(?!\[\[|\]\]).)+)\]\]', data)
|
|
link = re.search('\[\[((?:(?!\[\[|\]\]).)+)\]\]', data)
|
|
@@ -954,9 +932,7 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
|
|
|
|
|
file_src = '/image/' + tool.sha224_replace(file_name) + '.' + file_end
|
|
file_src = '/image/' + tool.sha224_replace(file_name) + '.' + file_end
|
|
|
file_alt = 'file:' + file_name + '.' + file_end
|
|
file_alt = 'file:' + file_name + '.' + file_end
|
|
|
-
|
|
|
|
|
- curs.execute(tool.db_change("select title from data where title = ?"), [file_alt])
|
|
|
|
|
- exist = curs.fetchall()
|
|
|
|
|
|
|
+ exist = None
|
|
|
|
|
|
|
|
if exist:
|
|
if exist:
|
|
|
data = re.sub(
|
|
data = re.sub(
|
|
@@ -972,23 +948,30 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
else:
|
|
else:
|
|
|
data = re.sub(
|
|
data = re.sub(
|
|
|
'\[\[((?:(?!\[\[|\]\]).)+)\]\]',
|
|
'\[\[((?:(?!\[\[|\]\]).)+)\]\]',
|
|
|
- '<a id="not_thing" href="/upload?name=' + tool.url_pas(file_name) + '">' + file_alt + '</a>',
|
|
|
|
|
|
|
+ '<span style="' + file_align + '">' + \
|
|
|
|
|
+ '<span style="' + file_color + '">' + \
|
|
|
|
|
+ '<img class="' + include_num + 'file_finder_1" style="' + file_style + '" alt="' + file_alt + '" src="' + file_src + '">' + \
|
|
|
|
|
+ '<a class="' + include_num + 'file_finder_2" id="not_thing" href="/upload?name=' + tool.url_pas(file_name) + '">' + file_alt + '</a>' + \
|
|
|
|
|
+ '</span>' + \
|
|
|
|
|
+ '</span>',
|
|
|
data,
|
|
data,
|
|
|
1
|
|
1
|
|
|
)
|
|
)
|
|
|
elif category_re.search(main_link):
|
|
elif category_re.search(main_link):
|
|
|
|
|
+ if category == '':
|
|
|
|
|
+ category += '<div id="cate_all"><hr><div id="cate">Category : '
|
|
|
|
|
+
|
|
|
main_link = category_re.sub('category:', main_link)
|
|
main_link = category_re.sub('category:', main_link)
|
|
|
|
|
|
|
|
|
|
+ curs.execute(tool.db_change("select title from data where title = ?"), [main_link])
|
|
|
if re.search('#blur', main_link):
|
|
if re.search('#blur', main_link):
|
|
|
see_link = 'Hidden'
|
|
see_link = 'Hidden'
|
|
|
link_id = 'id="inside"'
|
|
link_id = 'id="inside"'
|
|
|
|
|
|
|
|
main_link = re.sub('#blur', '', main_link)
|
|
main_link = re.sub('#blur', '', main_link)
|
|
|
- else:
|
|
|
|
|
- link_id = ''
|
|
|
|
|
|
|
|
|
|
backlink += [[title, main_link, 'cat']]
|
|
backlink += [[title, main_link, 'cat']]
|
|
|
- category += '<a ' + link_id + ' href="' + tool.url_pas(main_link) + '">' + category_re.sub('', see_link) + '</a> | '
|
|
|
|
|
|
|
+ category += '<a class="' + include_num + 'link_finder" href="/w/' + tool.url_pas(main_link) + '">' + category_re.sub('', see_link) + '</a> | '
|
|
|
|
|
|
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '', data, 1)
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '', data, 1)
|
|
|
elif re.search('^wiki:', main_link):
|
|
elif re.search('^wiki:', main_link):
|
|
@@ -1026,7 +1009,7 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
)
|
|
)
|
|
|
else:
|
|
else:
|
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', 'Not exist', data, 1)
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', 'Not exist', data, 1)
|
|
|
- elif re.search('^\/', main_link):
|
|
|
|
|
|
|
+ elif re.search('^(\/(?:.+))$', main_link):
|
|
|
under_title = re.search('^(\/(?:.+))$', main_link)
|
|
under_title = re.search('^(\/(?:.+))$', main_link)
|
|
|
under_title = under_title.groups()[0]
|
|
under_title = under_title.groups()[0]
|
|
|
|
|
|
|
@@ -1037,7 +1020,7 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
elif re.search('^http(s)?:\/\/', main_link):
|
|
elif re.search('^http(s)?:\/\/', main_link):
|
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<a id="out_link" rel="nofollow" href="' + main_link + '">' + see_link + '</a>', data, 1)
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]).)+)\]\]', '<a id="out_link" rel="nofollow" href="' + main_link + '">' + see_link + '</a>', data, 1)
|
|
|
else:
|
|
else:
|
|
|
- return_link = tool.link_fix(main_link)
|
|
|
|
|
|
|
+ return_link = link_fix(main_link)
|
|
|
main_link = html.unescape(return_link[0])
|
|
main_link = html.unescape(return_link[0])
|
|
|
other_link = return_link[1]
|
|
other_link = return_link[1]
|
|
|
|
|
|
|
@@ -1051,19 +1034,15 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
if not re.search('^\|', main_link):
|
|
if not re.search('^\|', main_link):
|
|
|
if main_link != title:
|
|
if main_link != title:
|
|
|
if main_link != '':
|
|
if main_link != '':
|
|
|
|
|
+ backlink += [[title, main_link, '']]
|
|
|
|
|
+
|
|
|
curs.execute(tool.db_change("select title from data where title = ?"), [main_link])
|
|
curs.execute(tool.db_change("select title from data where title = ?"), [main_link])
|
|
|
if not curs.fetchall():
|
|
if not curs.fetchall():
|
|
|
- link_id = 'id="not_thing"'
|
|
|
|
|
-
|
|
|
|
|
backlink += [[title, main_link, 'no']]
|
|
backlink += [[title, main_link, 'no']]
|
|
|
- else:
|
|
|
|
|
- link_id = ''
|
|
|
|
|
-
|
|
|
|
|
- backlink += [[title, main_link, '']]
|
|
|
|
|
|
|
|
|
|
data = re.sub(
|
|
data = re.sub(
|
|
|
'\[\[((?:(?!\[\[|\]\]).)+)\]\]',
|
|
'\[\[((?:(?!\[\[|\]\]).)+)\]\]',
|
|
|
- '<a ' + link_id + ' ' + \
|
|
|
|
|
|
|
+ '<a class="' + include_num + 'link_finder" ' + \
|
|
|
'title="' + main_link + other_link + '" ' + \
|
|
'title="' + main_link + other_link + '" ' + \
|
|
|
'href="/w/' + tool.url_pas(main_link) + other_link + '"' + \
|
|
'href="/w/' + tool.url_pas(main_link) + other_link + '"' + \
|
|
|
'>' + see_link + '</a>',
|
|
'>' + see_link + '</a>',
|
|
@@ -1189,14 +1168,14 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
if footdata[2] == 0:
|
|
if footdata[2] == 0:
|
|
|
footdata_in = ''
|
|
footdata_in = ''
|
|
|
else:
|
|
else:
|
|
|
- footdata_in = footdata[2]
|
|
|
|
|
|
|
+ footdata_in = str(footdata[2])
|
|
|
|
|
|
|
|
footdata_all += '' + \
|
|
footdata_all += '' + \
|
|
|
'<li>' + \
|
|
'<li>' + \
|
|
|
'<a href="#' + include_num + 'rfn-' + str(footdata[0]) + '" ' + \
|
|
'<a href="#' + include_num + 'rfn-' + str(footdata[0]) + '" ' + \
|
|
|
'id="' + include_num + 'cfn-' + str(footdata[0]) + '" ' + \
|
|
'id="' + include_num + 'cfn-' + str(footdata[0]) + '" ' + \
|
|
|
'onclick="do_open_foot(\'' + include_num + 'fn-' + str(footdata[0]) + '\', 1);">' + \
|
|
'onclick="do_open_foot(\'' + include_num + 'fn-' + str(footdata[0]) + '\', 1);">' + \
|
|
|
- '(' + footdata[1] + ')' + \
|
|
|
|
|
|
|
+ '(' + str(footdata[1]) + ')' + \
|
|
|
'</a> <span id="' + include_num + 'fn-' + str(footdata[0]) + '">' + footdata_in + '</span>' + \
|
|
'</a> <span id="' + include_num + 'fn-' + str(footdata[0]) + '">' + footdata_in + '</span>' + \
|
|
|
'</li>' + \
|
|
'</li>' + \
|
|
|
''
|
|
''
|
|
@@ -1208,31 +1187,28 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
|
|
|
|
|
data = re.sub('\n$', footdata_all, data + '\n', 1)
|
|
data = re.sub('\n$', footdata_all, data + '\n', 1)
|
|
|
|
|
|
|
|
- category += '</div></div>'
|
|
|
|
|
- category = re.sub(' \| <\/div><\/div>$', '</div></div>', category)
|
|
|
|
|
|
|
+ data = re.sub(''''(?P<in>((?!''').)+)'''', '<b>\g<in></b>', data)
|
|
|
|
|
+ data = re.sub('''(?P<in>((?!'').)+)''', '<i>\g<in></i>', data)
|
|
|
|
|
+ data = re.sub('~~(?P<in>(?:(?!~~).)+)~~', '<s>\g<in></s>', data)
|
|
|
|
|
+ data = re.sub('--(?P<in>(?:(?!--).)+)--', '<s>\g<in></s>', data)
|
|
|
|
|
+ data = re.sub('__(?P<in>(?:(?!__).)+)__', '<u>\g<in></u>', data)
|
|
|
|
|
+ data = re.sub('\^\^(?P<in>(?:(?!\^\^).)+)\^\^', '<sup>\g<in></sup>', data)
|
|
|
|
|
+ data = re.sub(',,(?P<in>(?:(?!,,).)+),,', '<sub>\g<in></sub>', data)
|
|
|
|
|
|
|
|
- if category == '<div id="cate_all"><hr><div id="cate">Category : </div></div>':
|
|
|
|
|
- category = ''
|
|
|
|
|
|
|
+ if category != '':
|
|
|
|
|
+ category = re.sub(' \| $', '', category) + '</div></div>'
|
|
|
|
|
|
|
|
data += category
|
|
data += category
|
|
|
|
|
|
|
|
- i = 0
|
|
|
|
|
- while 1:
|
|
|
|
|
- try:
|
|
|
|
|
- _ = end_data[i][0]
|
|
|
|
|
- except:
|
|
|
|
|
- break
|
|
|
|
|
-
|
|
|
|
|
- if end_data[i][2] == 'normal':
|
|
|
|
|
- data = data.replace('<span id="' + end_data[i][0] + '"></span>', end_data[i][1])
|
|
|
|
|
- data = data.replace(tool.url_pas('<span id="' + end_data[i][0] + '"></span>'), tool.url_pas(end_data[i][1]))
|
|
|
|
|
|
|
+ for i in end_data:
|
|
|
|
|
+ if end_data[i][1] == 'normal':
|
|
|
|
|
+ data = data.replace('<span id="' + i + '"></span>', end_data[i][0])
|
|
|
|
|
+ data = data.replace(tool.url_pas('<span id="' + i + '"></span>'), tool.url_pas(end_data[i][0]))
|
|
|
else:
|
|
else:
|
|
|
- if re.search('\n', end_data[i][1]):
|
|
|
|
|
- data = data.replace('<span id="' + end_data[i][0] + '"></span>', '\n<pre>' + re.sub('^\n', '', end_data[i][1]) + '</pre>')
|
|
|
|
|
|
|
+ if re.search('\n', end_data[i][0]):
|
|
|
|
|
+ data = data.replace('<span id="' + i + '"></span>', '\n<pre>' + re.sub('^\n', '', end_data[i][0]) + '</pre>')
|
|
|
else:
|
|
else:
|
|
|
- data = data.replace('<span id="' + end_data[i][0] + '"></span>', '<code>' + end_data[i][1] + '</code>')
|
|
|
|
|
-
|
|
|
|
|
- i += 1
|
|
|
|
|
|
|
+ data = data.replace('<span id="' + i + '"></span>', '<code>' + end_data[i][0] + '</code>')
|
|
|
|
|
|
|
|
if main_num == 1:
|
|
if main_num == 1:
|
|
|
i = 0
|
|
i = 0
|
|
@@ -1242,24 +1218,12 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
except:
|
|
except:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
- find_data = re.search('<span id="(one_nowiki_[0-9]+)">', backlink[i][1])
|
|
|
|
|
- if find_data:
|
|
|
|
|
- j = 0
|
|
|
|
|
- find_data = find_data.groups()[0]
|
|
|
|
|
-
|
|
|
|
|
- while 1:
|
|
|
|
|
- try:
|
|
|
|
|
- _ = end_data[j][0]
|
|
|
|
|
- except:
|
|
|
|
|
- break
|
|
|
|
|
-
|
|
|
|
|
- if end_data[j][0] == find_data:
|
|
|
|
|
- if backlink[i][2] != 'redirect':
|
|
|
|
|
- backlink[i][1] = backlink[i][1].replace('<span id="' + end_data[j][0] + '"></span>', end_data[j][1])
|
|
|
|
|
- else:
|
|
|
|
|
- backlink[i][1] = backlink[i][1].replace('<span id="' + end_data[j][0] + '"></span>', '\\' + end_data[j][1])
|
|
|
|
|
-
|
|
|
|
|
- j += 1
|
|
|
|
|
|
|
+ find_data = re.findall('<span id="(one_nowiki_[0-9]+)">', backlink[i][1])
|
|
|
|
|
+ for j in find_data:
|
|
|
|
|
+ if backlink[i][2] != 'redirect':
|
|
|
|
|
+ backlink[i][1] = backlink[i][1].replace('<span id="' + j + '"></span>', end_data[j][0])
|
|
|
|
|
+ else:
|
|
|
|
|
+ backlink[i][1] = backlink[i][1].replace('<span id="' + j + '"></span>', '\\' + end_data[j][0])
|
|
|
|
|
|
|
|
i += 1
|
|
i += 1
|
|
|
|
|
|
|
@@ -1278,6 +1242,6 @@ def namumark(conn, data, title, main_num, include_num):
|
|
|
data = re.sub('\n<\/ul>', '</ul>', data)
|
|
data = re.sub('\n<\/ul>', '</ul>', data)
|
|
|
data = re.sub('\n', '<br>', data)
|
|
data = re.sub('\n', '<br>', data)
|
|
|
|
|
|
|
|
- plus_data = '<script>render_html("' + include_num + 'render_contect");</script>' + plus_data
|
|
|
|
|
|
|
+ plus_data = 'render_html("' + include_num + 'render_contect");\n' + plus_data
|
|
|
|
|
|
|
|
return [data, plus_data, backlink]
|
|
return [data, plus_data, backlink]
|