mark.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from set_mark.start import start
  2. from set_mark.mid_pas import mid_pas
  3. from set_mark.html_pas import html_pas
  4. from set_mark.include_pas import include_pas
  5. from set_mark.macro import macro
  6. from set_mark.redirect_pas import redirect_pas
  7. from set_mark.blockquote import blockquote
  8. from set_mark.toc_pas import toc_pas
  9. from set_mark.text_help import text_help
  10. from set_mark.link import link
  11. from set_mark.indent import indent
  12. from set_mark.footnote import footnote
  13. from set_mark.table import table
  14. from set_mark.end import end
  15. import re
  16. import html
  17. import sqlite3
  18. from urllib import parse
  19. import time
  20. import threading
  21. def send_p(d):
  22. d = html.escape(d)
  23. js_p = re.compile('javascript:', re.I)
  24. d = js_p.sub('', d)
  25. d = re.sub('&lt;a href="(?:[^"]*)"&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + url_pas('\g<in>') + '">\g<in></a>', d)
  26. return d
  27. def url_pas(data):
  28. return parse.quote(data).replace('/','%2F')
  29. def plusing(conn, name, link, backtype):
  30. curs = conn.cursor()
  31. curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
  32. if not curs.fetchall():
  33. curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
  34. def namumark(conn, title, data, num, in_c, toc_y):
  35. # data += '<script>function folding(num, test = 0) { var fol = document.getElementById(\'folding_\' + num); if(fol.style.display == \'inline-block\' || fol.style.display == \'block\') { fol.style.display = \'none\'; } else { if(num % 3 == 0 && test != 1) { fol.style.display = \'block\'; } else { fol.style.display = \'inline-block\'; } } } </script>'
  36. #
  37. # if num == 1:
  38. # for d4 in backlink:
  39. # t = threading.Thread(target = plusing, args = [conn, d4[0], d4[1], d4[2]])
  40. # t.start()
  41. # t.join()
  42. #
  43. # conn.commit()
  44. return data