|
@@ -29,7 +29,7 @@ def link_fix(main_link):
|
|
|
|
|
|
|
|
other_link = re.search('[^\\\\]?(#[^#]+)$', main_link)
|
|
other_link = re.search('[^\\\\]?(#[^#]+)$', main_link)
|
|
|
if other_link:
|
|
if other_link:
|
|
|
- other_link = other_link.groups()[0]
|
|
|
|
|
|
|
+ other_link = other_link.group(1)
|
|
|
|
|
|
|
|
main_link = re.sub('(#[^#]+)$', '', main_link)
|
|
main_link = re.sub('(#[^#]+)$', '', main_link)
|
|
|
else:
|
|
else:
|
|
@@ -173,11 +173,11 @@ def table_start(data):
|
|
|
|
|
|
|
|
table = re.search('\n((?:(?:(?:(?:\|\||\|[^|]+\|)+(?:(?:(?!\|\|).\n*)*))+)\|\|(?:\n)?)+)', data)
|
|
table = re.search('\n((?:(?:(?:(?:\|\||\|[^|]+\|)+(?:(?:(?!\|\|).\n*)*))+)\|\|(?:\n)?)+)', data)
|
|
|
if table:
|
|
if table:
|
|
|
- table = re.sub('(\|\|)+\n', '||\n', table.groups()[0])
|
|
|
|
|
|
|
+ table = re.sub('(\|\|)+\n', '||\n', table.group(1))
|
|
|
|
|
|
|
|
table_caption = re.search('^\|([^|]+)\|', table)
|
|
table_caption = re.search('^\|([^|]+)\|', table)
|
|
|
if table_caption:
|
|
if table_caption:
|
|
|
- table_caption = '<caption>' + table_caption.groups()[0] + '</caption>'
|
|
|
|
|
|
|
+ table_caption = '<caption>' + table_caption.group(1) + '</caption>'
|
|
|
|
|
|
|
|
table = re.sub('^\|([^|]+)\|', '||', table)
|
|
table = re.sub('^\|([^|]+)\|', '||', table)
|
|
|
else:
|
|
else:
|
|
@@ -188,7 +188,7 @@ def table_start(data):
|
|
|
table_cel = re.findall('(\n(?:(?:\|\|)+)|\|\|\n(?:(?:\|\|)+)|(?:(?:\|\|)+))((?:(?:(?!\n|\|\|).)+\n*)+)', table)
|
|
table_cel = re.findall('(\n(?:(?:\|\|)+)|\|\|\n(?:(?:\|\|)+)|(?:(?:\|\|)+))((?:(?:(?!\n|\|\|).)+\n*)+)', table)
|
|
|
for i in table_cel:
|
|
for i in table_cel:
|
|
|
cel_plus = re.search('^((?:<(?:(?:(?!>).)*)>)+)', i[1])
|
|
cel_plus = re.search('^((?:<(?:(?:(?!>).)*)>)+)', i[1])
|
|
|
- cel_plus = cel_plus.groups()[0] if cel_plus else ''
|
|
|
|
|
|
|
+ cel_plus = cel_plus.group(1) if cel_plus else ''
|
|
|
cel_data = re.sub('^((?:<(?:(?:(?!>).)*)>)+)', '', i[1])
|
|
cel_data = re.sub('^((?:<(?:(?:(?!>).)*)>)+)', '', i[1])
|
|
|
|
|
|
|
|
if re.search('^\n', i[0]):
|
|
if re.search('^\n', i[0]):
|
|
@@ -285,22 +285,22 @@ def middle_parser(data, include_num):
|
|
|
middle_search = 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']
|
|
middle_list += ['span']
|
|
|
|
|
|
|
|
- data = middle_re.sub('<span style="color: ' + middle_search.groups()[0] + ';">', data, 1)
|
|
|
|
|
|
|
+ data = middle_re.sub('<span style="color: ' + middle_search.group(1) + ';">', data, 1)
|
|
|
elif re.search('^(?:#(\w+))', middle_data[0]):
|
|
elif re.search('^(?:#(\w+))', middle_data[0]):
|
|
|
middle_search = re.search('^(?:#(\w+))', middle_data[0])
|
|
middle_search = re.search('^(?:#(\w+))', middle_data[0])
|
|
|
middle_list += ['span']
|
|
middle_list += ['span']
|
|
|
|
|
|
|
|
- data = middle_re.sub('<span style="color: ' + middle_search.groups()[0] + ';">', data, 1)
|
|
|
|
|
|
|
+ data = middle_re.sub('<span style="color: ' + middle_search.group(1) + ';">', data, 1)
|
|
|
elif re.search('^(?:@((?:[0-9a-f-A-F]{3}){1,2}))', middle_data[0]):
|
|
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_search = re.search('^(?:@((?:[0-9a-f-A-F]{3}){1,2}))', middle_data[0])
|
|
|
middle_list += ['span']
|
|
middle_list += ['span']
|
|
|
|
|
|
|
|
- data = middle_re.sub('<span style="background: #' + middle_search.groups()[0] + ';">', data, 1)
|
|
|
|
|
|
|
+ data = middle_re.sub('<span style="background: #' + middle_search.group(1) + ';">', data, 1)
|
|
|
elif re.search('^(?:@(\w+))', middle_data[0]):
|
|
elif re.search('^(?:@(\w+))', middle_data[0]):
|
|
|
middle_search = re.search('^(?:@(\w+))', middle_data[0])
|
|
middle_search = re.search('^(?:@(\w+))', middle_data[0])
|
|
|
middle_list += ['span']
|
|
middle_list += ['span']
|
|
|
|
|
|
|
|
- data = middle_re.sub('<span style="background: ' + middle_search.groups()[0] + ';">', data, 1)
|
|
|
|
|
|
|
+ data = middle_re.sub('<span style="background: ' + middle_search.group(1) + ';">', data, 1)
|
|
|
elif re.search('^(\+|-)([1-5])', middle_data[0]):
|
|
elif re.search('^(\+|-)([1-5])', middle_data[0]):
|
|
|
middle_search = re.search('^(\+|-)([1-5])', middle_data[0])
|
|
middle_search = re.search('^(\+|-)([1-5])', middle_data[0])
|
|
|
middle_search = middle_search.groups()
|
|
middle_search = middle_search.groups()
|
|
@@ -502,7 +502,7 @@ def namumark(conn, data, title, include_num):
|
|
|
while 1:
|
|
while 1:
|
|
|
math = math_re.search(data)
|
|
math = math_re.search(data)
|
|
|
if math:
|
|
if math:
|
|
|
- math = math.groups()[0]
|
|
|
|
|
|
|
+ math = math.group(1)
|
|
|
math = math.replace('{', '<math_mid_1>')
|
|
math = math.replace('{', '<math_mid_1>')
|
|
|
math = math.replace('}', '<math_mid_2>')
|
|
math = math.replace('}', '<math_mid_2>')
|
|
|
math = math.replace('\\', '<math_slash>')
|
|
math = math.replace('\\', '<math_slash>')
|
|
@@ -520,7 +520,7 @@ def namumark(conn, data, title, include_num):
|
|
|
while 1:
|
|
while 1:
|
|
|
math = math_re.search(data)
|
|
math = math_re.search(data)
|
|
|
if math:
|
|
if math:
|
|
|
- math = math.groups()[0]
|
|
|
|
|
|
|
+ math = math.group(1)
|
|
|
math = math.replace('<math_mid_1>', '{')
|
|
math = math.replace('<math_mid_1>', '{')
|
|
|
math = math.replace('<math_mid_2>', '}')
|
|
math = math.replace('<math_mid_2>', '}')
|
|
|
math = math.replace('<math_slash>', '\\')
|
|
math = math.replace('<math_slash>', '\\')
|
|
@@ -562,11 +562,11 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
include = include_re.search(data)
|
|
include = include_re.search(data)
|
|
|
if include:
|
|
if include:
|
|
|
- include = include.groups()[0]
|
|
|
|
|
|
|
+ include = include.group(1)
|
|
|
|
|
|
|
|
include_data = re.search('^((?:(?!,).)+)', include)
|
|
include_data = re.search('^((?:(?!,).)+)', include)
|
|
|
if include_data:
|
|
if include_data:
|
|
|
- include_data = include_data.groups()[0]
|
|
|
|
|
|
|
+ include_data = include_data.group(1)
|
|
|
else:
|
|
else:
|
|
|
include_data = 'Test'
|
|
include_data = 'Test'
|
|
|
|
|
|
|
@@ -635,7 +635,7 @@ def namumark(conn, data, title, include_num):
|
|
|
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.group(1)
|
|
|
|
|
|
|
|
return_link = link_fix(redirect)
|
|
return_link = link_fix(redirect)
|
|
|
main_link = html.unescape(return_link[0])
|
|
main_link = html.unescape(return_link[0])
|
|
@@ -751,7 +751,7 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
now_time = tool.get_time()
|
|
now_time = tool.get_time()
|
|
|
time_data = re.search('^([0-9]{4}-[0-9]{2}-[0-9]{2})', now_time)
|
|
time_data = re.search('^([0-9]{4}-[0-9]{2}-[0-9]{2})', now_time)
|
|
|
- time = time_data.groups()[0]
|
|
|
|
|
|
|
+ time = time_data.group(1)
|
|
|
|
|
|
|
|
macro_re = re.compile('\[([^[(]+)\(((?:(?!\)]).)+)\)\]')
|
|
macro_re = re.compile('\[([^[(]+)\(((?:(?!\)]).)+)\)\]')
|
|
|
macro_data = macro_re.findall(data)
|
|
macro_data = macro_re.findall(data)
|
|
@@ -760,7 +760,7 @@ def namumark(conn, data, title, include_num):
|
|
|
if macro_name == 'youtube' or macro_name == 'kakaotv' or macro_name == 'nicovideo':
|
|
if macro_name == 'youtube' or macro_name == 'kakaotv' or macro_name == 'nicovideo':
|
|
|
width = re.search(', ?width=((?:(?!,).)+)', i[1])
|
|
width = re.search(', ?width=((?:(?!,).)+)', i[1])
|
|
|
if width:
|
|
if width:
|
|
|
- video_width = width.groups()[0]
|
|
|
|
|
|
|
+ video_width = width.group(1)
|
|
|
if re.search('^[0-9]+$', video_width):
|
|
if re.search('^[0-9]+$', video_width):
|
|
|
video_width += 'px'
|
|
video_width += 'px'
|
|
|
else:
|
|
else:
|
|
@@ -768,7 +768,7 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
height = re.search(', ?height=((?:(?!,).)+)', i[1])
|
|
height = re.search(', ?height=((?:(?!,).)+)', i[1])
|
|
|
if height:
|
|
if height:
|
|
|
- video_height = height.groups()[0]
|
|
|
|
|
|
|
+ video_height = height.group(1)
|
|
|
if re.search('^[0-9]+$', video_height):
|
|
if re.search('^[0-9]+$', video_height):
|
|
|
video_height += 'px'
|
|
video_height += 'px'
|
|
|
else:
|
|
else:
|
|
@@ -776,7 +776,7 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
code = re.search('^((?:(?!,).)+)', i[1])
|
|
code = re.search('^((?:(?!,).)+)', i[1])
|
|
|
if code:
|
|
if code:
|
|
|
- video_code = code.groups()[0]
|
|
|
|
|
|
|
+ video_code = code.group(1)
|
|
|
else:
|
|
else:
|
|
|
video_code = ''
|
|
video_code = ''
|
|
|
|
|
|
|
@@ -785,7 +785,7 @@ def namumark(conn, data, title, include_num):
|
|
|
if macro_name == 'youtube':
|
|
if macro_name == 'youtube':
|
|
|
start = re.search(', ?(start=(?:(?!,).)+)', i[1])
|
|
start = re.search(', ?(start=(?:(?!,).)+)', i[1])
|
|
|
if start:
|
|
if start:
|
|
|
- video_start = '?' + start.groups()[0]
|
|
|
|
|
|
|
+ video_start = '?' + start.group(1)
|
|
|
|
|
|
|
|
video_code = re.sub('^https:\/\/www\.youtube\.com\/watch\?v=', '', video_code)
|
|
video_code = re.sub('^https:\/\/www\.youtube\.com\/watch\?v=', '', video_code)
|
|
|
video_code = re.sub('^https:\/\/youtu\.be\/', '', video_code)
|
|
video_code = re.sub('^https:\/\/youtu\.be\/', '', video_code)
|
|
@@ -809,19 +809,19 @@ def namumark(conn, data, title, include_num):
|
|
|
elif macro_name == 'ruby':
|
|
elif macro_name == 'ruby':
|
|
|
ruby_code = re.search('^([^,]+)', i[1])
|
|
ruby_code = re.search('^([^,]+)', i[1])
|
|
|
if ruby_code:
|
|
if ruby_code:
|
|
|
- ruby_code = ruby_code.groups()[0]
|
|
|
|
|
|
|
+ ruby_code = ruby_code.group(1)
|
|
|
else:
|
|
else:
|
|
|
ruby_code = 'Test'
|
|
ruby_code = 'Test'
|
|
|
|
|
|
|
|
ruby_top = re.search('ruby=([^,]+)', i[1], flags = re.I)
|
|
ruby_top = re.search('ruby=([^,]+)', i[1], flags = re.I)
|
|
|
if ruby_top:
|
|
if ruby_top:
|
|
|
- ruby_top = ruby_top.groups()[0]
|
|
|
|
|
|
|
+ ruby_top = ruby_top.group(1)
|
|
|
else:
|
|
else:
|
|
|
ruby_top = 'Test'
|
|
ruby_top = 'Test'
|
|
|
|
|
|
|
|
ruby_color = re.search('color=([^,]+)', i[1], flags = re.I)
|
|
ruby_color = re.search('color=([^,]+)', i[1], flags = re.I)
|
|
|
if ruby_color:
|
|
if ruby_color:
|
|
|
- ruby_color = 'color: ' + ruby_color.groups()[0] + ';'
|
|
|
|
|
|
|
+ ruby_color = 'color: ' + ruby_color.group(1) + ';'
|
|
|
else:
|
|
else:
|
|
|
ruby_color = ''
|
|
ruby_color = ''
|
|
|
|
|
|
|
@@ -869,7 +869,7 @@ def namumark(conn, data, title, include_num):
|
|
|
while 1:
|
|
while 1:
|
|
|
block = re.search('(\n(?:> ?(?:(?:(?!\n).)+)?\n)+)', data)
|
|
block = re.search('(\n(?:> ?(?:(?:(?!\n).)+)?\n)+)', data)
|
|
|
if block:
|
|
if block:
|
|
|
- block = block.groups()[0]
|
|
|
|
|
|
|
+ block = block.group(1)
|
|
|
|
|
|
|
|
block = re.sub('^\n> ?', '', block)
|
|
block = re.sub('^\n> ?', '', block)
|
|
|
block = re.sub('\n> ?', '\n', block)
|
|
block = re.sub('\n> ?', '\n', block)
|
|
@@ -892,7 +892,7 @@ def namumark(conn, data, title, include_num):
|
|
|
while 1:
|
|
while 1:
|
|
|
li = re.search('(\n(?:(?: *)\* ?(?:(?:(?!\n).)+)\n)+)', data)
|
|
li = re.search('(\n(?:(?: *)\* ?(?:(?:(?!\n).)+)\n)+)', data)
|
|
|
if li:
|
|
if li:
|
|
|
- li = li.groups()[0]
|
|
|
|
|
|
|
+ li = li.group(1)
|
|
|
while 1:
|
|
while 1:
|
|
|
sub_li = re.search('\n(?:( *)\* ?((?:(?!\n).)+))', li)
|
|
sub_li = re.search('\n(?:( *)\* ?((?:(?!\n).)+))', li)
|
|
|
if sub_li:
|
|
if sub_li:
|
|
@@ -917,7 +917,7 @@ def namumark(conn, data, title, include_num):
|
|
|
while 1:
|
|
while 1:
|
|
|
indent = re.search('\n( +)', data)
|
|
indent = re.search('\n( +)', data)
|
|
|
if indent:
|
|
if indent:
|
|
|
- indent = len(indent.groups()[0])
|
|
|
|
|
|
|
+ indent = len(indent.group(1))
|
|
|
|
|
|
|
|
margin = '<span style="margin-left: 20px;"></span>' * indent
|
|
margin = '<span style="margin-left: 20px;"></span>' * indent
|
|
|
|
|
|
|
@@ -932,7 +932,7 @@ def namumark(conn, data, title, include_num):
|
|
|
while 1:
|
|
while 1:
|
|
|
link = re.search('\[\[((?:(?!\[\[|\]\]|<\/td>).)+)\]\]', data)
|
|
link = re.search('\[\[((?:(?!\[\[|\]\]|<\/td>).)+)\]\]', data)
|
|
|
if link:
|
|
if link:
|
|
|
- link = link.groups()[0]
|
|
|
|
|
|
|
+ link = link.group(1)
|
|
|
|
|
|
|
|
link_split = re.search('((?:(?!\|).)+)(?:\|((?:(?!\|).)+))', link)
|
|
link_split = re.search('((?:(?!\|).)+)(?:\|((?:(?!\|).)+))', link)
|
|
|
if link_split:
|
|
if link_split:
|
|
@@ -949,7 +949,7 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
file_width = re.search('width=((?:(?!&).)+)', see_link)
|
|
file_width = re.search('width=((?:(?!&).)+)', see_link)
|
|
|
if file_width:
|
|
if file_width:
|
|
|
- file_width = file_width.groups()[0]
|
|
|
|
|
|
|
+ file_width = file_width.group(1)
|
|
|
if re.search('px$', file_width):
|
|
if re.search('px$', file_width):
|
|
|
file_style += 'width: ' + file_width + ';'
|
|
file_style += 'width: ' + file_width + ';'
|
|
|
else:
|
|
else:
|
|
@@ -957,7 +957,7 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
file_height = re.search('height=((?:(?!&).)+)', see_link)
|
|
file_height = re.search('height=((?:(?!&).)+)', see_link)
|
|
|
if file_height:
|
|
if file_height:
|
|
|
- file_height = file_height.groups()[0]
|
|
|
|
|
|
|
+ file_height = file_height.group(1)
|
|
|
if re.search('px$', file_height):
|
|
if re.search('px$', file_height):
|
|
|
file_style += 'height: ' + file_height + ';'
|
|
file_style += 'height: ' + file_height + ';'
|
|
|
else:
|
|
else:
|
|
@@ -965,7 +965,7 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
file_align = re.search('align=((?:(?!&).)+)', see_link)
|
|
file_align = re.search('align=((?:(?!&).)+)', see_link)
|
|
|
if file_align:
|
|
if file_align:
|
|
|
- file_align = file_align.groups()[0]
|
|
|
|
|
|
|
+ file_align = file_align.group(1)
|
|
|
if file_align == 'center':
|
|
if file_align == 'center':
|
|
|
file_align = 'display: block; text-align: center;'
|
|
file_align = 'display: block; text-align: center;'
|
|
|
else:
|
|
else:
|
|
@@ -975,7 +975,7 @@ def namumark(conn, data, title, include_num):
|
|
|
|
|
|
|
|
file_color = re.search('bgcolor=((?:(?!&).)+)', see_link)
|
|
file_color = re.search('bgcolor=((?:(?!&).)+)', see_link)
|
|
|
if file_color:
|
|
if file_color:
|
|
|
- file_color = 'background: ' + file_color.groups()[0] + '; display: inline-block;'
|
|
|
|
|
|
|
+ file_color = 'background: ' + file_color.group(1) + '; display: inline-block;'
|
|
|
else:
|
|
else:
|
|
|
file_color = ''
|
|
file_color = ''
|
|
|
|
|
|
|
@@ -1078,7 +1078,7 @@ def namumark(conn, data, title, include_num):
|
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]|<\/td>).)+)\]\]', 'Not exist', data, 1)
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]|<\/td>).)+)\]\]', '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.group(1)
|
|
|
|
|
|
|
|
if see_link != main_link:
|
|
if see_link != main_link:
|
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]|<\/td>).)+)\]\]', '[[' + title + under_title + '|' + see_link + ']]', data, 1)
|
|
data = re.sub('\[\[((?:(?!\[\[|\]\]|<\/td>).)+)\]\]', '[[' + title + under_title + '|' + see_link + ']]', data, 1)
|