mark.py 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. from bottle import request, app
  2. from bottle.ext import beaker
  3. from urllib import parse
  4. import json
  5. import sqlite3
  6. import time
  7. import re
  8. import hashlib
  9. import html
  10. import datetime
  11. import time
  12. json_data = open('set.json').read()
  13. set_data = json.loads(json_data)
  14. conn = sqlite3.connect(set_data['db'] + '.db')
  15. curs = conn.cursor()
  16. session_opts = {
  17. 'session.type': 'dbm',
  18. 'session.data_dir': './app_session/',
  19. 'session.auto': 1
  20. }
  21. app = beaker.middleware.SessionMiddleware(app(), session_opts)
  22. def get_time():
  23. now = time.localtime()
  24. date = "%04d-%02d-%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec)
  25. return(date)
  26. def ip_check():
  27. session = request.environ.get('beaker.session')
  28. try:
  29. if(session.get('Now') == 1):
  30. ip = format(session['DREAMER'])
  31. else:
  32. if(request.environ.get('HTTP_X_FORWARDED_FOR')):
  33. ip = request.environ.get('HTTP_X_FORWARDED_FOR')
  34. else:
  35. ip = request.environ.get('REMOTE_ADDR')
  36. except:
  37. ip = 'None'
  38. return(ip)
  39. def url_pas(data):
  40. return(parse.quote(data).replace('/','%2F'))
  41. def sha224(data):
  42. return(hashlib.sha224(bytes(data, 'utf-8')).hexdigest())
  43. def savemark(data):
  44. data = re.sub("\[date\(now\)\]", get_time(), data)
  45. if(not re.search("\.", ip_check())):
  46. name = '[[사용자:' + ip_check() + '|' + ip_check() + ']]'
  47. else:
  48. name = ip_check()
  49. data = re.sub("\[name\]", name, data)
  50. return(data)
  51. def send_p(d):
  52. d = html.escape(d)
  53. js_p = re.compile('javascript:', re.I)
  54. d = js_p.sub('', d)
  55. d = re.sub('&lt;a href="(?:[^"]*)"&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + url_pas('\g<in>') + '">\g<in></a>', d)
  56. return(d)
  57. def table_p(d, d2):
  58. table_class = 'class="'
  59. alltable = 'style="'
  60. celstyle = 'style="'
  61. rowstyle = 'style="'
  62. row = ''
  63. cel = ''
  64. table_w = re.search("&lt;table\s?width=((?:(?!&gt;).)*)&gt;", d)
  65. table_h = re.search("&lt;table\s?height=((?:(?!&gt;).)*)&gt;", d)
  66. table_a = re.search("&lt;table\s?align=((?:(?!&gt;).)*)&gt;", d)
  67. if(table_w):
  68. alltable += 'width: ' + table_w.groups()[0] + ';'
  69. if(table_h):
  70. alltable += 'height: ' + table_h.groups()[0] + ';'
  71. if(table_a):
  72. if(table_a.groups()[0] == 'right'):
  73. alltable += 'float: right;'
  74. elif(table_a.groups()[0] == 'center'):
  75. alltable += 'margin: auto;'
  76. table_t_a = re.search("&lt;table\s?textalign=((?:(?!&gt;).)*)&gt;", d)
  77. if(table_t_a):
  78. if(table_t_a.groups()[0] == 'right'):
  79. alltable += 'text-align: right;'
  80. elif(table_t_a.groups()[0] == 'center'):
  81. alltable += 'text-align: center;'
  82. row_t_a = re.search("&lt;row\s?textalign=((?:(?!&gt;).)*)&gt;", d)
  83. if(row_t_a):
  84. if(row_t_a.groups()[0] == 'right'):
  85. rowstyle += 'text-align: right;'
  86. elif(row_t_a.groups()[0] == 'center'):
  87. rowstyle += 'text-align: center;'
  88. else:
  89. rowstyle += 'text-align: left;'
  90. table_cel = re.search("&lt;-((?:(?!&gt;).)*)&gt;", d)
  91. if(table_cel):
  92. cel = 'colspan="' + table_cel.groups()[0] + '"'
  93. else:
  94. cel = 'colspan="' + str(round(len(d2) / 2)) + '"'
  95. table_row = re.search("&lt;\|((?:(?!&gt;).)*)&gt;", d)
  96. if(table_row):
  97. row = 'rowspan="' + table_row.groups()[0] + '"'
  98. row_bgcolor_2 = re.search("&lt;rowbgcolor=(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
  99. row_bgcolor_3 = re.search("&lt;rowbgcolor=(\w+)&gt;", d)
  100. if(row_bgcolor_2):
  101. rowstyle += 'background: ' + row_bgcolor_2.groups()[0] + ';'
  102. elif(row_bgcolor_3):
  103. rowstyle += 'background: ' + row_bgcolor_3.groups()[0] + ';'
  104. table_border_2 = re.search("&lt;table\s?bordercolor=(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
  105. table_border_3 = re.search("&lt;table\s?bordercolor=(\w+)&gt;", d)
  106. if(table_border_2):
  107. alltable += 'border: ' + table_border_2.groups()[0] + ' 2px solid;'
  108. elif(table_border_3):
  109. alltable += 'border: ' + table_border_3.groups()[0] + ' 2px solid;'
  110. table_bgcolor_2 = re.search("&lt;table\s?bgcolor=(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
  111. table_bgcolor_3 = re.search("&lt;table\s?bgcolor=(\w+)&gt;", d)
  112. if(table_bgcolor_2):
  113. alltable += 'background: ' + table_bgcolor_2.groups()[0] + ';'
  114. elif(table_bgcolor_3):
  115. alltable += 'background: ' + table_bgcolor_3.groups()[0] + ';'
  116. bgcolor_2 = re.search("&lt;(?:bgcolor=)?(#(?:[0-9a-f-A-F]{3}){1,2})&gt;", d)
  117. bgcolor_3 = re.search("&lt;(?:bgcolor=)?(\w+)&gt;", d)
  118. if(bgcolor_2):
  119. celstyle += 'background: ' + bgcolor_2.groups()[0] + ';'
  120. elif(bgcolor_3):
  121. celstyle += 'background: ' + bgcolor_3.groups()[0] + ';'
  122. n_width = re.search("&lt;width=((?:(?!&gt;).)*)&gt;", d)
  123. n_height = re.search("&lt;height=((?:(?!&gt;).)*)&gt;", d)
  124. if(n_width):
  125. celstyle += 'width: ' + n_width.groups()[0] + ';'
  126. if(n_height):
  127. celstyle += 'height: ' + n_height.groups()[0] + ';'
  128. text_right = re.search("&lt;\)&gt;", d)
  129. text_center = re.search("&lt;:&gt;", d)
  130. text_left = re.search("&lt;\(&gt;", d)
  131. if(text_right):
  132. celstyle += 'text-align: right;'
  133. elif(text_center):
  134. celstyle += 'text-align: center;'
  135. elif(text_left):
  136. celstyle += 'text-align: left;'
  137. text_class = re.search("&lt;table\s?class=((?:(?!&gt;).)+)&gt;", d)
  138. if(text_class):
  139. d = text_class.groups()
  140. table_class += d[0]
  141. alltable += '"'
  142. celstyle += '"'
  143. rowstyle += '"'
  144. table_class += '"'
  145. return([alltable, rowstyle, celstyle, row, cel, table_class])
  146. def html_pas(data):
  147. data = re.sub('%H%', '<', data)
  148. data = re.sub('%\/H%', '>', data)
  149. d_list = re.findall('<(\/)?([^> ]+)( (?:[^>]+)?)?>', data)
  150. for i_list in d_list:
  151. if(i_list[0] == ''):
  152. if(i_list[1] in ['div', 'span', 'embed', 'iframe']):
  153. if(re.search('<\/' + i_list[1] + '>', data)):
  154. src = re.search('src=([^ ]*)', i_list[2])
  155. if(src):
  156. v_src = re.search('http(?:s)?:\/\/([^/\'" ]*)', src.groups()[0])
  157. if(v_src):
  158. if(not v_src.groups()[0] in ["www.youtube.com", "serviceapi.nmv.naver.com", "tv.kakao.com", "www.google.com", "serviceapi.rmcnmv.naver.com"]):
  159. ot = re.sub('src=([^ ]*)', '', i_list[2])
  160. else:
  161. ot = i_list[2]
  162. else:
  163. ot = re.sub('src=([^ ]*)', '', i_list[2])
  164. else:
  165. ot = i_list[2]
  166. po = re.compile('position', re.I)
  167. data = data.replace('<' + i_list[1] + i_list[2] + '>', '%H%' + i_list[1] + po.sub('', ot) + '%/H%', 1)
  168. data = re.sub('<\/' + i_list[1] + '>', '%H%/' + i_list[1] + '%/H%', data, 1)
  169. data = html.escape(data)
  170. end = re.findall('%H%((?:(?!%/H%).)*)%/H%', data)
  171. for d_end in end:
  172. data = re.sub('%H%((?:(?!%/H%).)*)%/H%', '<' + re.sub('&quot;', '"', re.sub('&#x27;', "'", d_end)) + '>', data, 1)
  173. return(data)
  174. def mid_pas(data, fol_num, include, in_c):
  175. p = re.compile('{{{((?:(?:(?:\+|-)[0-5])|(?:#|@)(?:(?:[0-9a-f-A-F]{3}){1,2}|(?:\w+))|(?:#!(?:html|wiki|noin|folding|syntax)))(?:(?!{{{|}}}).)+)}}}', re.DOTALL)
  176. while(1):
  177. m = p.search(data)
  178. if(m):
  179. d = m.groups()
  180. data = p.sub('###' + d[0] + '/###', data, 1)
  181. else:
  182. break
  183. com = re.compile("{{{((?:(?!{{{|}}}).)*)}}}", re.DOTALL)
  184. while(1):
  185. m = com.search(data)
  186. if(m):
  187. d = m.groups()
  188. data = com.sub('<code>' + d[0] + '</code>', data, 1)
  189. else:
  190. break
  191. com3 = re.compile('###((?:(?!\/###).)+)\/###', re.DOTALL)
  192. m = com3.search(data)
  193. while(1):
  194. m = com3.search(data)
  195. if(m):
  196. d = m.groups()
  197. data = com3.sub('{{{' + d[0] + '}}}', data, 1)
  198. else:
  199. break
  200. com2 = re.compile("<code>((?:(?!(?:<code>|<\/code>)).)*)<\/code>", re.DOTALL)
  201. da_com = com2.findall(data)
  202. for com_da in da_com:
  203. mid_data = com_da.replace('<', '&lt;').replace('>', '&gt;')
  204. mid_data = re.sub("(?P<in>.)", "#no#\g<in>#/no#", mid_data)
  205. data = com2.sub(mid_data, data, 1)
  206. while(1):
  207. is_it = com.search(data)
  208. if(is_it):
  209. it_d = is_it.groups()[0]
  210. big_a = re.compile("^\+([1-5])\s(.*)$", re.DOTALL)
  211. big = big_a.search(it_d)
  212. small_a = re.compile("^\-([1-5])\s(.*)$", re.DOTALL)
  213. small = small_a.search(it_d)
  214. color_b = re.compile("^(#(?:[0-9a-f-A-F]{3}){1,2})\s(.*)$", re.DOTALL)
  215. color_2 = color_b.search(it_d)
  216. color_c = re.compile("^#(\w+)\s(.*)$", re.DOTALL)
  217. color_3 = color_c.search(it_d)
  218. back_a = re.compile("^@((?:[0-9a-f-A-F]{3}){1,2})\s(.*)$", re.DOTALL)
  219. back = back_a.search(it_d)
  220. back_c = re.compile("^@(\w+)\s(.*)$", re.DOTALL)
  221. back_3 = back_c.search(it_d)
  222. include_out_a = re.compile("^#!noin\s(.*)$", re.DOTALL)
  223. include_out = include_out_a.search(it_d)
  224. div_a = re.compile("^#!wiki\sstyle=(?:&quot;|&#x27;)((?:(?!&quot;|&#x27;).)*)(?:&quot;|&#x27;)\r\n(.*)$", re.DOTALL)
  225. div = div_a.search(it_d)
  226. html_a = re.compile("^#!html\s(.*)$", re.DOTALL)
  227. html = html_a.search(it_d)
  228. fol_a = re.compile("^#!folding\s((?:(?!\n).)*)\n?\s\n(.*)$", re.DOTALL)
  229. fol = fol_a.search(it_d)
  230. syn_a = re.compile("^#!syntax\s([^\n]*)\r\n(.*)$", re.DOTALL)
  231. syn = syn_a.search(it_d)
  232. if(big):
  233. big_d = big.groups()
  234. data = com.sub('<span style="font-size: ' + str(int(big_d[0]) * 20 + 100) + '%;">' + big_d[1] + '</span>', data, 1)
  235. elif(small):
  236. sm_d = small.groups()
  237. data = com.sub('<span style="font-size: ' + str(100 - int(sm_d[0]) * 10) + '%;">' + sm_d[1] + '</span>', data, 1)
  238. elif(color_2):
  239. c_d_2 = color_2.groups()
  240. data = com.sub('<span style="color: ' + c_d_2[0] + '">' + c_d_2[1] + '</span>', data, 1)
  241. elif(color_3):
  242. c_d_3 = color_3.groups()
  243. data = com.sub('<span style="color: ' + c_d_3[0] + '">' + c_d_3[1] + '</span>', data, 1)
  244. elif(back):
  245. back_d_1 = back.groups()
  246. data = com.sub('<span style="background: #' + back_d_1[0] + '">' + back_d_1[1] + '</span>', data, 1)
  247. elif(back_3):
  248. back_d_3 = back_3.groups()
  249. data = com.sub('<span style="background: ' + back_d_3[0] + '">' + back_d_3[1] + '</span>', data, 1)
  250. elif(div):
  251. div_d = div.groups()
  252. data = com.sub('<div style="' + div_d[0] + '">' + div_d[1] + '</div>', data, 1)
  253. elif(html):
  254. data = com.sub(html.groups()[0], data, 1)
  255. elif(fol):
  256. fol_d = fol.groups()
  257. data = com.sub( "<div> \
  258. " + fol_d[0] + " \
  259. <div id='folding_" + str(fol_num + 1) + "' style='display: inline-block;'> \
  260. [<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>펼치기</a>] \
  261. </div> \
  262. <div id='folding_" + str(fol_num + 2) + "' style='display: none;'> \
  263. [<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>접기</a>] \
  264. </div> \
  265. <div id='folding_" + str(fol_num) + "' style='display: none;'> \
  266. <br> \
  267. " + fol_d[1] + " \
  268. </div> \
  269. </div>", data, 1)
  270. fol_num += 3
  271. elif(syn):
  272. syn_d = syn.groups()
  273. data = com.sub('<pre id="syntax"><code class="' + syn_d[0] + '"><code>' + re.sub('\r\n', '<isbr>', re.sub(' ', '<space>', syn_d[1])) + '</code></code></pre>', data, 1)
  274. elif(include_out):
  275. if((include or in_c) == 1):
  276. data = com.sub("", data, 1)
  277. else:
  278. data = com.sub(include_out.groups()[0], data, 1)
  279. else:
  280. data = com.sub(it_d, data, 1)
  281. else:
  282. break
  283. com2 = re.compile("<code>((?:(?!(?:<code>|<\/code>)).)*)<\/code>", re.DOTALL)
  284. da_com = com2.findall(data)
  285. for com_da in da_com:
  286. mid_data = com_da.replace('<', '&lt;').replace('>', '&gt;')
  287. mid_data = re.sub("(?P<in>.)", "#no#\g<in>#/no#", mid_data)
  288. data = com2.sub(mid_data, data, 1)
  289. return([data, fol_num])
  290. def toc_pas(data, title, num, toc_y):
  291. i = [0, 0, 0, 0, 0, 0, 0]
  292. last = 0
  293. toc_c = -1
  294. toc_d = -1
  295. span = ''
  296. rtoc = '<div id="toc"><span id="toc-name">목차</span><br><br>'
  297. while(1):
  298. i[0] += 1
  299. m = re.search('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\r\n', data)
  300. if(m):
  301. result = m.groups()
  302. wiki = len(result[0])
  303. if(last < wiki):
  304. last = wiki
  305. else:
  306. last = wiki
  307. for a in range(wiki + 1, 7):
  308. i[a] = 0
  309. i[wiki] += 1
  310. toc = str(i[1]) + '.' + str(i[2]) + '.' + str(i[3]) + '.' + str(i[4]) + '.' + str(i[5]) + '.' + str(i[6]) + '.'
  311. toc = re.sub("(?P<in>[0-9]0(?:[0]*)?)\.", '\g<in>#.', toc)
  312. toc = re.sub("0\.", '', toc)
  313. toc = re.sub("#\.", '.', toc)
  314. toc = re.sub("\.$", '', toc)
  315. if(toc_c == -1):
  316. margin = 'style="margin-top: 30px;"'
  317. toc_c = toc.count('.')
  318. else:
  319. toc_d = toc.count('.')
  320. if(toc_c == toc_d):
  321. margin = 'style="margin-top: 30px;"'
  322. else:
  323. if(toc_d < toc_c):
  324. margin = 'style="margin-top: 30px;"'
  325. else:
  326. margin = ''
  327. toc_c = toc_d
  328. t = toc.count('.')
  329. span = '<span style="margin-left: 5px;"></span>' * t
  330. rtoc += span + '<a href="#s-' + toc + '">' + toc + '</a>. ' + result[1] + '<br>'
  331. c = re.sub(" $", "", result[1])
  332. d = c
  333. c = re.sub("\[\[(([^|]*)\|)?(?P<in>[^\]]*)\]\]", "\g<in>", c)
  334. edit_d = ''
  335. if(toc_y == 1):
  336. edit_d = ' <span style="font-size:11px;">[<a href="/edit/' + url_pas(title) + '/section/' + str(i[0]) + '">편집</a>]</span>'
  337. data = re.sub('(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n', '<tablenobr><h' + str(wiki) + ' id="' + c + '" ' + margin + '><a href="#toc" id="s-' + toc + '">' + toc + '.<span style="margin-left: 5px;"></span></a> ' + d + edit_d + '</h' + str(wiki) + '><hr style="margin-top: -5px;">\n', data, 1)
  338. else:
  339. rtoc += '</div>'
  340. break
  341. data = re.sub("\[목차\]", rtoc, data)
  342. return(data)
  343. def link(title, data, num, num2, category):
  344. m = re.findall("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", data)
  345. for g in m:
  346. if(title != g):
  347. backlink_plus(title, g, 'cat', num)
  348. if(category == ''):
  349. curs.execute("select title from data where title = ?", [g])
  350. exists = curs.fetchall()
  351. if(exists):
  352. red = ""
  353. else:
  354. red = 'class="not_thing"'
  355. category += '<a ' + red + ' href="/w/' + url_pas(g) + '">' + re.sub("분류:", "", g) + '</a>'
  356. else:
  357. curs.execute("select title from data where title = ?", [g])
  358. exists = curs.fetchall()
  359. if(exists):
  360. red = ""
  361. else:
  362. red = 'class="not_thing"'
  363. category += ' / ' + '<a ' + red + ' href="/w/' + url_pas(g) + '">' + re.sub("분류:", "", g) + '</a>'
  364. data = re.sub("\[\[(분류:(?:(?:(?!\]\]).)*))\]\]", '', data, 1)
  365. test = re.findall('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', data)
  366. if(test):
  367. for wiki in test:
  368. if(wiki[1]):
  369. data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + wiki[1] + '</a>', data, 1)
  370. else:
  371. data = re.sub('\[\[wiki:([^|\]]+)(?:\|([^\]]+))?\]\]', '<a id="inside" href="/' + wiki[0] + '">' + wiki[0] + '</a>', data, 1)
  372. data = re.sub("\[\[(?::(?P<in>(?:분류|파일):(?:(?:(?!\]\]).)*)))\]\]", "[[\g<in>]]", data)
  373. a = re.findall('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', data)
  374. for i in a:
  375. b = re.search('(.*)\/', title)
  376. if(b):
  377. m = b.groups()
  378. if(i):
  379. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + m[0] + i + ']]', data, 1)
  380. else:
  381. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + m[0] + ']]', data, 1)
  382. else:
  383. if(i):
  384. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + title + i + ']]', data, 1)
  385. else:
  386. data = re.sub('\[\[\.\.\/(\|(?:[^\]]*))?\]\]', '[[' + title + ']]', data, 1)
  387. data = re.sub('\[\[(?P<in>\/[^\]|]*)(?P<out>\|(?:[^\]]*))?\]\]', '[[' + title + '\g<in>\g<out>]]', data)
  388. link = re.compile('\[\[((?:(?!\[\[|\]\]|\|).)*)(?:\|((?:(?!\[\[|\]\]).)*))?\]\]')
  389. while(1):
  390. l_d = link.search(data)
  391. if(l_d):
  392. d = l_d.groups()
  393. if(re.search('^(?:파일|외부):', d[0])):
  394. width = ''
  395. height = ''
  396. align = ''
  397. span = ['', '']
  398. try:
  399. w_d = re.search('width=([0-9]+(?:[a-z%]+)?)', d[1])
  400. if(w_d):
  401. width = 'width="' + w_d.groups()[0] + '" '
  402. h_d = re.search('height=([0-9]+(?:[a-z%]+)?)', d[1])
  403. if(h_d):
  404. height = 'height="' + h_d.groups()[0] + '" '
  405. a_d = re.search('align=(center|right)', d[1])
  406. if(a_d):
  407. span[0] = '<span style="display: block; text-align: ' + a_d.groups()[0] + ';">'
  408. span[1] = '</span>'
  409. except:
  410. pass
  411. f_d = re.search('^파일:([^.]+)\.(.+)$', d[0])
  412. if(f_d):
  413. if(not re.search("^파일:([^\n]*)", title)):
  414. if(num == 1):
  415. backlink_plus(title, d[0], 'file', num2)
  416. img = span[0] + '<img src="/image/' + sha224(f_d.groups()[0]) + '.' + f_d.groups()[1] + '" ' + width + height + '>' + span[1]
  417. data = link.sub(img, data, 1)
  418. else:
  419. img = span[0] + '<img src="' + re.sub('^외부:', '', d[0]) + '" ' + width + height + '>' + span[1]
  420. data = link.sub(img, data, 1)
  421. elif(re.search('^https?:\/\/', d[0])):
  422. view = d[0]
  423. try:
  424. if(re.search('(.+)', d[1])):
  425. view = d[1]
  426. except:
  427. pass
  428. data = link.sub('<a class="out_link" rel="nofollow" href="' + d[0] + '">' + view + '</a>', data, 1)
  429. else:
  430. view = d[0].replace('\\', '')
  431. try:
  432. if(re.search('(.+)', d[1])):
  433. view = d[1]
  434. except:
  435. pass
  436. sh = ''
  437. s_d = re.search('#((?:(?!x27;|#).)+)$', d[0])
  438. if(s_d):
  439. href = re.sub('#((?:(?!x27;|#).)+)$', '', d[0])
  440. sh = '#' + s_d.groups()[0]
  441. else:
  442. href = d[0]
  443. if(d[0] == title):
  444. data = link.sub('<b>' + view + '</b>', data, 1)
  445. elif(re.search('^#', d[0])):
  446. data = link.sub('<a href="' + url_pas(href.replace('\\', '')) + sh + '">' + view + '</a>', data, 1)
  447. else:
  448. if(num == 1):
  449. backlink_plus(title, href.replace('\\', ''), '', num2)
  450. curs.execute("select title from data where title = ?", [href.replace('\\', '')])
  451. if(not curs.fetchall()):
  452. no = 'class="not_thing"'
  453. if(num == 1):
  454. backlink_plus(title, href.replace('\\', ''), 'no', num2)
  455. else:
  456. no = ''
  457. a = href.replace('\\', '').replace('&#x27;', "'").replace('&quot;', '"')
  458. data = link.sub('<a ' + no + ' title="' + a + sh + '" href="/w/' + url_pas(a) + sh + '">' + view + '</a>', data, 1)
  459. else:
  460. break
  461. return([data, category])
  462. def backlink_plus(name, link, backtype, num):
  463. if(num == 1):
  464. curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
  465. d = curs.fetchall()
  466. if(not d):
  467. try:
  468. curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
  469. except:
  470. while(1):
  471. try:
  472. curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
  473. break
  474. except:
  475. time.sleep(1)
  476. def namumark(title, data, num, in_c, toc_y):
  477. data = re.sub("\n", "\r\n", re.sub("\r\n", "\n", data))
  478. data = html_pas(data)
  479. data = '\r\n' + data + '\r\n'
  480. fol_num = 0
  481. var_d = mid_pas(data, fol_num, 0, in_c)
  482. data = var_d[0]
  483. fol_num = var_d[1]
  484. category = ''
  485. include = re.compile("\[include\(((?:(?!\)\]|,).)*)((?:(?:,\s?(?:(?!\)\]).)*))+)?\)\]")
  486. m = include.findall(data)
  487. for results in m:
  488. if(results[0] == title):
  489. data = include.sub("<b>" + results[0] + "</b>", data, 1)
  490. else:
  491. curs.execute("select data from data where title = ?", [results[0]])
  492. in_con = curs.fetchall()
  493. backlink_plus(title, results[0], 'include', num)
  494. if(in_con):
  495. in_data = in_con[0][0]
  496. in_data = include.sub("", in_data)
  497. in_data = re.sub("\n", "\r\n", re.sub("\r\n", "\n", in_data))
  498. in_data = html_pas(in_data)
  499. var_d = mid_pas(in_data, fol_num, 1, in_c)
  500. var_d2 = link(title, var_d[0], num, 0, category)
  501. in_data = var_d2[0]
  502. category = var_d2[1]
  503. fol_num = var_d[1]
  504. if(results[1]):
  505. a = results[1]
  506. while(1):
  507. g = re.search("([^= ,]*)\=([^,]*)", a)
  508. if(g):
  509. result = g.groups()
  510. in_data = re.sub("@" + result[0] + "@", result[1], in_data)
  511. a = re.sub("([^= ,]*)\=([^,]*)", "", a, 1)
  512. else:
  513. break
  514. in_data = toc_pas(in_data, results[0], num, toc_y)
  515. data = include.sub('\n<nobr><a id="include_link" href="/w/' + url_pas(results[0]) + '">[' + results[0] + ' 이동]</a><div>' + in_data + '</div><nobr>\n', data, 1)
  516. else:
  517. data = include.sub("<a class=\"not_thing\" href=\"/w/" + url_pas(results[0]) + "\">" + results[0] + "</a>", data, 1)
  518. data = re.sub("\r\n##\s?([^\n]*)\r\n", "\r\n", data)
  519. data = re.sub("\[anchor\((?P<in>[^\[\]]*)\)\]", '<span id="\g<in>"></span>', data)
  520. data = savemark(data)
  521. d_re = re.findall('\r\n#(?:redirect|넘겨주기) ((?:(?!\r|\n|%0D).)+)', data)
  522. for d in d_re:
  523. view = d.replace('\\', '')
  524. sh = ''
  525. s_d = re.search('#((?:(?!x27;|#).)+)$', d)
  526. if(s_d):
  527. href = re.sub('#((?:(?!x27;|#).)+)$', '', d)
  528. sh = '#' + s_d.groups()[0]
  529. else:
  530. href = d
  531. data = re.sub('\r\n#(?:redirect|넘겨주기) ((?:(?!\r|\n|%0D).)+)', '<meta http-equiv="refresh" content="0;url=/w/' + url_pas(href.replace('\\', '').replace('&#x27;', "'").replace('&quot;', '"')) + '/from/' + url_pas(title) + sh + '" />', data, 1)
  532. data = re.sub("\[nicovideo\((?P<in>[^,)]*)(?:(?:,(?:[^,)]*))+)?\)\]", "[[http://embed.nicovideo.jp/watch/\g<in>]]", data)
  533. while(1):
  534. m = re.search("\n&gt;\s?((?:[^\n]*)(?:(?:(?:(?:\n&gt;\s?)(?:[^\n]*))+)?))", data)
  535. if(m):
  536. result = m.groups()
  537. blockquote = result[0]
  538. blockquote = re.sub("\n&gt;\s?", "\n", blockquote)
  539. data = re.sub("\n&gt;\s?((?:[^\n]*)(?:(?:(?:(?:\n&gt;\s?)(?:[^\n]*))+)?))", "\n<blockquote>" + blockquote + "</blockquote>", data, 1)
  540. else:
  541. break
  542. if(not re.search('\[목차\]', data)):
  543. if(not re.search('\[목차\(없음\)\]', data)):
  544. data = re.sub("(?P<in>(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "[목차]\n\g<in>", data, 1)
  545. else:
  546. data = re.sub("\[목차\(없음\)\]", "", data)
  547. data = re.sub("(\n)(?P<in>\r\n(={1,6})\s?([^=]*)\s?(?:={1,6})(?:\s+)?\n)", "\g<in>", data)
  548. data = toc_pas(data, title, num, toc_y)
  549. data = re.sub("&#x27;&#x27;&#x27;(?P<in>(?:(?!&#x27;&#x27;&#x27;).)*)&#x27;&#x27;&#x27;", '<b>\g<in></b>', data)
  550. data = re.sub("&#x27;&#x27;(?P<in>(?:(?!&#x27;&#x27;).)*)&#x27;&#x27;", '<i>\g<in></i>', data)
  551. data = re.sub('(?:~~|--)(?P<in>(?:(?!~~|--).)+)(?:~~|--)', '<s>\g<in></s>', data)
  552. data = re.sub('__(?P<in>.+?)__(?!_)', '<u>\g<in></u>', data)
  553. data = re.sub('\^\^(?P<in>.+?)\^\^(?!\^)', '<sup>\g<in></sup>', data)
  554. data = re.sub(',,(?P<in>.+?),,(?!,)', '<sub>\g<in></sub>', data)
  555. data = re.sub('&lt;math&gt;(?P<in>((?!&lt;math&gt;).)*)&lt;\/math&gt;', '[math]\g<in>[/math]', data)
  556. data = re.sub('{{\|(?P<in>(?:(?:(?:(?!\|}}).)*)(?:\n?))+)\|}}', '<table><tbody><tr><td>\g<in></td></tr></tbody></table>', data)
  557. data = re.sub('\[ruby\((?P<in>[^\,]*)\,\s?(?P<out>[^\)]*)\)\]', '<ruby>\g<in><rp>(</rp><rt>\g<out></rt><rp>)</rp></ruby>', data)
  558. data = re.sub("\[br\]", '<br>', data)
  559. while(1):
  560. com = re.compile("\[youtube\(([^, )]*)(,[^)]*)?\)\]")
  561. m = com.search(data)
  562. if(m):
  563. src = ''
  564. width = '560'
  565. height = '315'
  566. time = '0'
  567. result = m.groups()
  568. if(result[0]):
  569. yudt = re.search('(?:\?v=(.*)|\/([^/?]*)|^([a-zA-Z0-9\-_]*))$', result[0])
  570. if(yudt):
  571. if(yudt.groups()[0]):
  572. src = yudt.groups()[0]
  573. elif(yudt.groups()[1]):
  574. src = yudt.groups()[1]
  575. elif(yudt.groups()[2]):
  576. src = yudt.groups()[2]
  577. else:
  578. src = ''
  579. if(result[1]):
  580. mdata = re.search('width=([0-9%]*)', result[1])
  581. if(mdata):
  582. width = mdata.groups()[0]
  583. mdata = re.search('height=([0-9%]*)', result[1])
  584. if(mdata):
  585. height = mdata.groups()[0]
  586. mdata = re.search('time=([0-9]*)', result[1])
  587. if(mdata):
  588. time = mdata.groups()[0]
  589. data = com.sub('<iframe width="' + width + '" height="' + height + '" src="https://www.youtube.com/embed/' + src + '?start=' + time + '" frameborder="0" allowfullscreen></iframe><br>', data, 1)
  590. else:
  591. break
  592. var_d2 = link(title, data, num, 1, category)
  593. data = var_d2[0]
  594. category = var_d2[1]
  595. while(1):
  596. m = re.search("(\n(?:(?:( +)\*\s(?:[^\n]*))\n?)+)", data)
  597. if(m):
  598. result = m.groups()
  599. end = str(result[0])
  600. while(1):
  601. isspace = re.search("( +)\*\s([^\n]*)", end)
  602. if(isspace):
  603. spacebar = isspace.groups()
  604. up = len(spacebar[0]) * 20
  605. end = re.sub("( +)\*\s([^\n]*)", "<li style='margin-left:" + str(up) + "px'>" + spacebar[1] + "</li>", end, 1)
  606. else:
  607. break
  608. end = re.sub("\n", '', end)
  609. data = re.sub("(\n(?:(?:( +)\*\s(?:[^\n]*))\n?)+)", '<ul style="margin-top: 10px; margin-bottom: 10px;" id="list">' + end + '</ul>', data, 1)
  610. else:
  611. break
  612. now_time = get_time()
  613. data = re.sub('\[date\]', now_time, data)
  614. time_data = re.search('^([0-9]{4}-[0-9]{2}-[0-9]{2})', now_time)
  615. time = time_data.groups()
  616. age_data = re.findall('\[age\(([0-9]{4}-[0-9]{2}-[0-9]{2})\)\]', data)
  617. for age in age_data:
  618. old = datetime.datetime.strptime(time[0], '%Y-%m-%d')
  619. will = datetime.datetime.strptime(age, '%Y-%m-%d')
  620. e_data = old - will
  621. data = re.sub('\[age\(([0-9]{4})-([0-9]{2})-([0-9]{2})\)\]', str(int(int(e_data.days) / 365)), data, 1)
  622. dday_data = re.findall('\[dday\(([0-9]{4}-[0-9]{2}-[0-9]{2})\)\]', data)
  623. for dday in dday_data:
  624. old = datetime.datetime.strptime(time[0], '%Y-%m-%d')
  625. will = datetime.datetime.strptime(dday, '%Y-%m-%d')
  626. e_data = old - will
  627. if(re.search('^-', str(e_data.days))):
  628. e_day = str(e_data.days)
  629. else:
  630. e_day = '+' + str(e_data.days)
  631. data = re.sub('\[dday\(([0-9]{4}-[0-9]{2}-[0-9]{2})\)\]', e_day, data, 1)
  632. data = re.sub("-{4,11}", "<hr>", data)
  633. while(1):
  634. b = re.search("(<\/h[0-9]>|\n)( +)", data)
  635. if(b):
  636. result = b.groups()
  637. up = re.sub(' ', '<span id="in"></span>', result[1])
  638. if(re.search('<\/h[0-9]>', result[0])):
  639. data = re.sub("(?P<in>\/h[0-9]>)( +)", '\g<in>' + up, data, 1)
  640. else:
  641. data = re.sub("(?:\n)( +)", '<br>' + up, data, 1)
  642. else:
  643. break
  644. a = 1
  645. tou = "<hr style='margin-top: 30px;' id='footnote'><div><br>"
  646. namu = []
  647. pop_re = re.compile('(?:\[\*([^\s]*)(?:\s((?:(?!\[|\]).)*))?\]|(\[각주\]))')
  648. while(1):
  649. b = pop_re.search(data)
  650. if(b):
  651. results = b.groups()
  652. try:
  653. if(not results[1] and results[0]):
  654. i = 0
  655. while(1):
  656. try:
  657. if(namu[i] == results[0]):
  658. none_this = 0
  659. break
  660. else:
  661. i += 2
  662. except:
  663. none_this = 1
  664. break
  665. if(none_this == 0):
  666. data = pop_re.sub("<sup> \
  667. <a href='javascript:void(0);' onclick='folding(" + str(fol_num) + ");' id='rfn-" + str(a) + "'>[" + results[0] + "]</a> \
  668. </sup> \
  669. <div class='popup' style='display: none;' id='folding_" + str(fol_num) + "'> \
  670. <a onclick='folding(" + str(fol_num) + ");' href='#fn-" + str(a) + "'>#d#" + results[0] + "#/d#</a> <a href='javascript:void(0);' onclick='folding(" + str(fol_num) + ");'>[X]</a> " + namu[i + 1] + " \
  671. </div>", data, 1)
  672. else:
  673. data = pop_re.sub("<sup> \
  674. <a href='javascript:void(0);' id='rfn-" + str(a) + "'>#d#" + results[0] + "#/d#</a> \
  675. </sup>", data, 1)
  676. else:
  677. if(results[0]):
  678. namu += [results[0]]
  679. namu += [results[1]]
  680. tou += "<span id='footnote-list'><a href='#rfn-" + str(a) + "' id='fn-" + str(a) + "'>[" + results[0] + "]</a> " + results[1] + "</span><br>"
  681. data = pop_re.sub("<sup> \
  682. <a href='javascript:void(0);' onclick='folding(" + str(fol_num) + ");' id='rfn-" + str(a) + "'>#d#" + results[0] + "#/d#</a> \
  683. </sup> \
  684. <div class='popup' style='display: none;' id='folding_" + str(fol_num) + "'> \
  685. <a onclick='folding(" + str(fol_num) + ");' href='#fn-" + str(a) + "'>#d#" + results[0] + "#/d#</a> <a href='javascript:void(0);' onclick='folding(" + str(fol_num) + ");'>#d#X#/d#</a> " + results[1] + " \
  686. </div>", data, 1)
  687. else:
  688. tou += "<span id='footnote-list'><a href='#rfn-" + str(a) + "' id='fn-" + str(a) + "'>[" + str(a) + "]</a> " + results[1] + "</span><br>"
  689. data = pop_re.sub('<sup> \
  690. <a href="javascript:void(0);" onclick="folding(' + str(fol_num) + ');" id="rfn-' + str(a) + '">#d#' + str(a) + '#/d#</a> \
  691. </sup> \
  692. <div class="popup" style="display: none;" id="folding_' + str(fol_num) + '"> \
  693. <a onclick="folding(' + str(fol_num) + ');" href="#fn-' + str(a) + '">#d#' + str(a) + '#/d#</a> <a href="javascript:void(0);" onclick="folding(' + str(fol_num) + ');">#d#X#/d#</a> ' + results[1] + ' \
  694. </div>', data, 1)
  695. a += 1
  696. fol_num += 2
  697. except:
  698. tou += '</div>'
  699. if(tou == "<hr style='margin-top: 30px;' id='footnote'><div><br></div>"):
  700. tou = ""
  701. else:
  702. tou = re.sub('#d#(?P<in>(?:(?!#\/d#).)*)#\/d#', '[\g<in>]', tou)
  703. data = pop_re.sub("<br>" + tou, data, 1)
  704. tou = "<hr style='margin-top: 30px;' id='footnote'><div><br>"
  705. else:
  706. tou += '</div>'
  707. if(tou == "<hr style='margin-top: 30px;' id='footnote'><div><br></div>"):
  708. tou = ""
  709. else:
  710. tou = re.sub('#d#(?P<in>(?:(?!#\/d#).)*)#\/d#', '[\g<in>]', tou)
  711. break
  712. data = re.sub('#d#(?P<in>(?:(?!#\/d#).)*)#\/d#', '[\g<in>]', data)
  713. data = re.sub("\[각주\](?:(?:<br>| |\r|\n)+)?$", "", data)
  714. data = re.sub("(?:(?:<br>| |\r|\n)+)$", "", data)
  715. data += tou
  716. if(category):
  717. data += '<div style="margin-top: 30px;" id="cate">분류: ' + category + '</div>'
  718. data = re.sub("(?:\|\|\r\n)", "#table#<tablenobr>", data)
  719. while(1):
  720. y = re.search("(\|\|(?:(?:(?:(?:(?!\|\|).)*)(?:\n?))+))", data)
  721. if(y):
  722. a = y.groups()
  723. mid_data = re.sub("\|\|", "#table#", a[0])
  724. mid_data = re.sub("\r\n", "<br>", mid_data)
  725. data = re.sub("(\|\|((?:(?:(?:(?!\|\|).)*)(?:\n?))+))", mid_data, data, 1)
  726. else:
  727. break
  728. data = re.sub("#table#", "||", data)
  729. data = re.sub("<tablenobr>", "\r\n", data)
  730. while(1):
  731. m = re.search("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", data)
  732. if(m):
  733. results = m.groups()
  734. table = results[0]
  735. while(1):
  736. a = re.search("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  737. if(a):
  738. row = ''
  739. cel = ''
  740. celstyle = ''
  741. rowstyle = ''
  742. alltable = ''
  743. table_d = ''
  744. result = a.groups()
  745. if(result[1]):
  746. table_d = table_p(result[1], result[0])
  747. alltable = table_d[0]
  748. rowstyle = table_d[1]
  749. celstyle = table_d[2]
  750. row = table_d[3]
  751. cel = table_d[4]
  752. table_class = table_d[5]
  753. table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "<table " + table_class + " " + alltable + "> \
  754. <tbody> \
  755. <tr " + rowstyle + "> \
  756. <td " + cel + " " + row + " " + celstyle + ">", table, 1)
  757. else:
  758. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  759. table = re.sub("^(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "<table> \
  760. <tbody> \
  761. <tr> \
  762. <td " + cel + ">", table, 1)
  763. else:
  764. break
  765. table = re.sub("\|\|$", "</td> \
  766. </tr> \
  767. </tbody> \
  768. </table>", table)
  769. while(1):
  770. b = re.search("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  771. if(b):
  772. row = ''
  773. cel = ''
  774. celstyle = ''
  775. rowstyle = ''
  776. table_d = ''
  777. result = b.groups()
  778. if(result[1]):
  779. table_d = table_p(result[1], result[0])
  780. rowstyle = table_d[1]
  781. celstyle = table_d[2]
  782. row = table_d[3]
  783. cel = table_d[4]
  784. table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  785. </tr> \
  786. <tr " + rowstyle + "> \
  787. <td " + cel + " " + row + " " + celstyle + ">", table, 1)
  788. else:
  789. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  790. table = re.sub("\|\|\r\n(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  791. </tr> \
  792. <tr> \
  793. <td " + cel + ">", table, 1)
  794. else:
  795. break
  796. while(1):
  797. c = re.search("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", table)
  798. if(c):
  799. row = ''
  800. cel = ''
  801. celstyle = ''
  802. table_d = ''
  803. result = c.groups()
  804. if(result[1]):
  805. table_d = table_p(result[1], result[0])
  806. celstyle = table_d[2]
  807. row = table_d[3]
  808. cel = table_d[4]
  809. table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  810. <td " + cel + " " + row + " " + celstyle + ">", table, 1)
  811. else:
  812. cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'
  813. table = re.sub("(\|\|(?:(?:\|\|)+)?)((?:&lt;(?:(?:(?!&gt;).)*)&gt;)+)?", "</td> \
  814. <td " + cel + ">", table, 1)
  815. else:
  816. break
  817. data = re.sub("(\|\|(?:(?:(?:.*)\n?)\|\|)+)", table, data, 1)
  818. else:
  819. break
  820. data = re.sub("\r\n(?P<in><h[0-6])", "\g<in>", data)
  821. data = re.sub("(\n<nobr>|<nobr>\n|<nobr>)", "", data)
  822. data = re.sub("#no#(?P<in>.)#\/no#", "\g<in>", data)
  823. data = re.sub("&lt;space&gt;", " ", data)
  824. data = re.sub('<\/blockquote>(?:(?:\r)?\n){2}<blockquote>', '</blockquote><blockquote>', data)
  825. data = re.sub('<\/blockquote>(?:(?:\r)?\n)<br><blockquote>', '</blockquote><blockquote>', data)
  826. data = re.sub('\n', '<br>', data)
  827. data = re.sub('<hr style="margin-top: -5px;"><br>', '<hr style="margin-top: -5px;">', data)
  828. data = re.sub('&lt;isbr&gt;', '\r\n', data)
  829. data = re.sub('^(?:<br>|\r|\n| )+', '', data)
  830. data = re.sub('^<div style="margin-top: 30px;" id="cate">', '<div id="cate">', data)
  831. if(num == 1):
  832. conn.commit()
  833. return(data)