|
@@ -1,6 +1,6 @@
|
|
|
import re
|
|
import re
|
|
|
|
|
|
|
|
-def table_p(d, d2):
|
|
|
|
|
|
|
+def table_p(d, d2, d3, num = 0):
|
|
|
table_class = 'class="'
|
|
table_class = 'class="'
|
|
|
alltable = 'style="'
|
|
alltable = 'style="'
|
|
|
celstyle = 'style="'
|
|
celstyle = 'style="'
|
|
@@ -23,6 +23,7 @@ def table_p(d, d2):
|
|
|
|
|
|
|
|
table_t_a = re.search("<table\s?textalign=((?:(?!>).)*)>", d)
|
|
table_t_a = re.search("<table\s?textalign=((?:(?!>).)*)>", d)
|
|
|
if(table_t_a):
|
|
if(table_t_a):
|
|
|
|
|
+ num = 1
|
|
|
if(table_t_a.groups()[0] == 'right'):
|
|
if(table_t_a.groups()[0] == 'right'):
|
|
|
alltable += 'text-align: right;'
|
|
alltable += 'text-align: right;'
|
|
|
elif(table_t_a.groups()[0] == 'center'):
|
|
elif(table_t_a.groups()[0] == 'center'):
|
|
@@ -91,6 +92,13 @@ def table_p(d, d2):
|
|
|
celstyle += 'text-align: center;'
|
|
celstyle += 'text-align: center;'
|
|
|
elif(text_left):
|
|
elif(text_left):
|
|
|
celstyle += 'text-align: left;'
|
|
celstyle += 'text-align: left;'
|
|
|
|
|
+ elif(num == 0):
|
|
|
|
|
+ if(re.search('^ (.*) $', d3)):
|
|
|
|
|
+ celstyle += 'text-align: center;'
|
|
|
|
|
+ elif(re.search('^ (.*)$', d3)):
|
|
|
|
|
+ celstyle += 'text-align: right;'
|
|
|
|
|
+ elif(re.search('^(.*) $', d3)):
|
|
|
|
|
+ celstyle += 'text-align: left;'
|
|
|
|
|
|
|
|
text_class = re.search("<table\s?class=((?:(?!>).)+)>", d)
|
|
text_class = re.search("<table\s?class=((?:(?!>).)+)>", d)
|
|
|
if(text_class):
|
|
if(text_class):
|
|
@@ -102,7 +110,7 @@ def table_p(d, d2):
|
|
|
rowstyle += '"'
|
|
rowstyle += '"'
|
|
|
table_class += '"'
|
|
table_class += '"'
|
|
|
|
|
|
|
|
- return([alltable, rowstyle, celstyle, row, cel, table_class])
|
|
|
|
|
|
|
+ return([alltable, rowstyle, celstyle, row, cel, table_class, num])
|
|
|
|
|
|
|
|
def table(data):
|
|
def table(data):
|
|
|
data = re.sub("(?:\|\|\r\n)", "#table#<tablenobr>", data)
|
|
data = re.sub("(?:\|\|\r\n)", "#table#<tablenobr>", data)
|
|
@@ -128,7 +136,7 @@ def table(data):
|
|
|
results = m.groups()
|
|
results = m.groups()
|
|
|
table = results[0]
|
|
table = results[0]
|
|
|
while(1):
|
|
while(1):
|
|
|
- a = re.search("^(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", table)
|
|
|
|
|
|
|
+ a = re.search("^(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)((?:(?!\|\|).)*)", table)
|
|
|
if(a):
|
|
if(a):
|
|
|
row = ''
|
|
row = ''
|
|
|
cel = ''
|
|
cel = ''
|
|
@@ -136,28 +144,30 @@ def table(data):
|
|
|
rowstyle = ''
|
|
rowstyle = ''
|
|
|
alltable = ''
|
|
alltable = ''
|
|
|
table_d = ''
|
|
table_d = ''
|
|
|
|
|
+ num = 0
|
|
|
|
|
|
|
|
result = a.groups()
|
|
result = a.groups()
|
|
|
if(result[1]):
|
|
if(result[1]):
|
|
|
- table_d = table_p(result[1], result[0])
|
|
|
|
|
|
|
+ table_d = table_p(result[1], result[0], result[2])
|
|
|
alltable = table_d[0]
|
|
alltable = table_d[0]
|
|
|
rowstyle = table_d[1]
|
|
rowstyle = table_d[1]
|
|
|
celstyle = table_d[2]
|
|
celstyle = table_d[2]
|
|
|
row = table_d[3]
|
|
row = table_d[3]
|
|
|
cel = table_d[4]
|
|
cel = table_d[4]
|
|
|
table_class = table_d[5]
|
|
table_class = table_d[5]
|
|
|
|
|
+ num = table_d[6]
|
|
|
|
|
|
|
|
- table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "<table " + table_class + " " + alltable + "><tbody><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
|
|
|
|
|
|
|
+ table = re.sub("^(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)", "<table " + table_class + " " + alltable + "><tbody><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
|
|
|
else:
|
|
else:
|
|
|
cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
|
|
cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
|
|
|
- table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "<table><tbody><tr><td " + cel + ">", table, 1)
|
|
|
|
|
|
|
+ table = re.sub("^(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)", "<table><tbody><tr><td " + cel + ">", table, 1)
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
table = re.sub("\|\|$", "</td></tr></tbody></table>", table)
|
|
table = re.sub("\|\|$", "</td></tr></tbody></table>", table)
|
|
|
|
|
|
|
|
while(1):
|
|
while(1):
|
|
|
- b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", table)
|
|
|
|
|
|
|
+ b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)((?:(?!\|\|).)*)", table)
|
|
|
if(b):
|
|
if(b):
|
|
|
row = ''
|
|
row = ''
|
|
|
cel = ''
|
|
cel = ''
|
|
@@ -167,21 +177,21 @@ def table(data):
|
|
|
|
|
|
|
|
result = b.groups()
|
|
result = b.groups()
|
|
|
if(result[1]):
|
|
if(result[1]):
|
|
|
- table_d = table_p(result[1], result[0])
|
|
|
|
|
|
|
+ table_d = table_p(result[1], result[0], result[2], num)
|
|
|
rowstyle = table_d[1]
|
|
rowstyle = table_d[1]
|
|
|
celstyle = table_d[2]
|
|
celstyle = table_d[2]
|
|
|
row = table_d[3]
|
|
row = table_d[3]
|
|
|
cel = table_d[4]
|
|
cel = table_d[4]
|
|
|
|
|
|
|
|
- table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td></tr><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
|
|
|
|
|
|
|
+ table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)", "</td></tr><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
|
|
|
else:
|
|
else:
|
|
|
cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
|
|
cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
|
|
|
- table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td></tr><tr><td " + cel + ">", table, 1)
|
|
|
|
|
|
|
+ table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)", "</td></tr><tr><td " + cel + ">", table, 1)
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
while(1):
|
|
while(1):
|
|
|
- c = re.search("(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", table)
|
|
|
|
|
|
|
+ c = re.search("(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)((?:(?!\|\|).)*)", table)
|
|
|
if(c):
|
|
if(c):
|
|
|
row = ''
|
|
row = ''
|
|
|
cel = ''
|
|
cel = ''
|
|
@@ -190,15 +200,15 @@ def table(data):
|
|
|
|
|
|
|
|
result = c.groups()
|
|
result = c.groups()
|
|
|
if(result[1]):
|
|
if(result[1]):
|
|
|
- table_d = table_p(result[1], result[0])
|
|
|
|
|
|
|
+ table_d = table_p(result[1], result[0], result[2], num)
|
|
|
celstyle = table_d[2]
|
|
celstyle = table_d[2]
|
|
|
row = table_d[3]
|
|
row = table_d[3]
|
|
|
cel = table_d[4]
|
|
cel = table_d[4]
|
|
|
|
|
|
|
|
- table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td><td " + cel + " " + row + " " + celstyle + ">", table, 1)
|
|
|
|
|
|
|
+ table = re.sub("(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)", "</td><td " + cel + " " + row + " " + celstyle + ">", table, 1)
|
|
|
else:
|
|
else:
|
|
|
cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
|
|
cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
|
|
|
- table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:<(?:(?:(?!>).)*)>)+)?", "</td><td " + cel + ">", table, 1)
|
|
|
|
|
|
|
+ table = re.sub("(\|\|(?:(?:\|\|)*))((?:<(?:(?:(?!>).)*)>)*)", "</td><td " + cel + ">", table, 1)
|
|
|
else:
|
|
else:
|
|
|
break
|
|
break
|
|
|
|
|
|