mark.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. from set_mark.start import *
  2. from set_mark.html_pas import *
  3. from set_mark.mid_pas import *
  4. from set_mark.include import *
  5. from set_mark.macro import *
  6. from set_mark.redirect_pas import *
  7. from set_mark.blockquote import *
  8. from set_mark.toc import *
  9. from set_mark.text_help import *
  10. from set_mark.link import *
  11. from set_mark.indent import *
  12. from set_mark.footnote import *
  13. from set_mark.table import *
  14. from set_mark.end import *
  15. import re
  16. import asyncio
  17. def send_p(d):
  18. d = html.escape(d)
  19. js_p = re.compile('javascript:', re.I)
  20. d = js_p.sub('', d)
  21. d = re.sub('&lt;a href="(?:[^"]*)"&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + url_pas('\g<in>') + '">\g<in></a>', d)
  22. return(d)
  23. async def plusing(name, link, backtype):
  24. curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
  25. if(not curs.fetchall()):
  26. curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
  27. return('')
  28. def namumark(title, data, num, in_c, toc_y):
  29. data = start(data)
  30. data = html_pas(data)
  31. fol_num = 0
  32. data = mid_pas(data, fol_num, 0, in_c)
  33. a = include(data, title, in_c, num, toc_y, fol_num)
  34. data = a[0]
  35. category = a[1]
  36. fol_num = a[2]
  37. backlink = a[3]
  38. data = re.sub("\r\n##\s?([^\n]*)\r\n", "\r\n", data)
  39. data = savemark(data)
  40. a = redirect_pas(data, backlink)
  41. data = a[0]
  42. backlink = a[1]
  43. data = blockquote(data)
  44. data = toc_pas(data, title, num, toc_y)
  45. data = text_help(data)
  46. data = macro(data)
  47. a = link(title, data, num, category, backlink)
  48. data = a[0]
  49. category = a[1]
  50. backlink = a[2]
  51. data = indent(data)
  52. data = footnote(data, fol_num)
  53. data = table(data)
  54. data = end(data, category)
  55. if(num == 1):
  56. asyncio.set_event_loop(asyncio.new_event_loop())
  57. loop = asyncio.get_event_loop()
  58. for d4 in back_list:
  59. loop.run_until_complete(plusing(d4[0], d4[1], d4[2]))
  60. loop.close()
  61. conn.commit()
  62. return(data)