Просмотр исходного кода

Merge pull request #325 from 2DU/master

Master
ect (or 2du) 8 лет назад
Родитель
Сommit
729cd18b63
8 измененных файлов с 25 добавлено и 13 удалено
  1. 1 1
      app.py
  2. 1 1
      set_mark/end.py
  3. 2 1
      set_mark/html_pas.py
  4. 5 2
      set_mark/include_pas.py
  5. 2 2
      set_mark/indent.py
  6. 1 1
      set_mark/mark.py
  7. 11 4
      set_mark/mid_pas.py
  8. 2 1
      set_mark/table.py

+ 1 - 1
app.py

@@ -1432,7 +1432,7 @@ def preview(name = None, num = None):
          
     newdata = request.forms.content
     newdata = re.sub('^#(?:redirect|넘겨주기) (?P<in>[^\n]*)', ' * [[\g<in>]] 문서로 넘겨주기', newdata)
-    enddata = namumark(conn, name, newdata, 0, 0, 0)
+    enddata = namumark(conn, name, newdata, 0, 0, 1)
     captcha = captcha_get(conn)
 
     if(num):

+ 1 - 1
set_mark/end.py

@@ -13,7 +13,7 @@ def end(data, category):
     data = re.sub('<\/blockquote>(?:(?:\r)?\n)<br><blockquote>', '</blockquote><blockquote>', data)
 
     data = re.sub('\n', '<br>', data)
-    data = re.sub('<hr style="margin-top: -5px;"><br>', '<hr style="margin-top: -5px;">', data)
+    data = re.sub('<hr id="under_bar"([^>]*)><br>', '<hr style="margin-top: -5px;">', data)
     data = re.sub('&lt;isbr&gt;', '\r\n', data)
     data = re.sub('^(?:<br>|\r|\n| )+', '', data)
     data = re.sub('^<div style="margin-top: 30px;" id="cate">', '<div id="cate">', data)        

+ 2 - 1
set_mark/html_pas.py

@@ -13,8 +13,9 @@ def html_pas(data):
                     src = re.search('src=([^ ]*)', i_list[2])
                     if(src):
                         v_src = re.search('http(?:s)?:\/\/([^/\'" ]*)', src.groups()[0])
+                        data_list = ["www.youtube.com", "serviceapi.nmv.naver.com", "tv.kakao.com", "www.google.com", "serviceapi.rmcnmv.naver.com"]
                         if(v_src):
-                            if(not v_src.groups()[0] in ["www.youtube.com", "serviceapi.nmv.naver.com", "tv.kakao.com", "www.google.com", "serviceapi.rmcnmv.naver.com"]):
+                            if(not v_src.groups()[0] in data_list):
                                 ot = re.sub('src=([^ ]*)', '', i_list[2])
                             else:
                                 ot = i_list[2]

+ 5 - 2
set_mark/include_pas.py

@@ -31,7 +31,7 @@ def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
                 in_data = re.sub("\n", "\r\n", re.sub("\r\n", "\n", in_data))
                 in_data = html_pas.html_pas(in_data)
                 
-                var_d = mid_pas.mid_pas(in_data, fol_num, 1, in_c)
+                var_d = mid_pas.mid_pas(in_data, fol_num, 1, in_c, toc_y)
                 var_d2 = link.link(conn, title, var_d[0], 0, category, backlink)
 
                 in_data = var_d2[0]
@@ -54,7 +54,10 @@ def include_pas(conn, data, title, in_c, num, toc_y, fol_num):
                 if(results[2]):
                     test = '<br>'
                 else:
-                    test = ''
+                    if(re.search('\|\|', in_data)):
+                        test = '\n'
+                    else:
+                        test = ''
 
                 data = include.sub('<nobr><a id="include_link" href="/w/' + url_pas(results[0]) + '">[' + results[0] + ' 이동]</a><br><span>' + in_data + '</span>' + test, data, 1)
             else:

+ 2 - 2
set_mark/indent.py

@@ -8,7 +8,7 @@ def indent(data):
             end = str(result[0])
 
             while(1):
-                isspace = re.search("( *)\*\s([^\n]*)", end)
+                isspace = re.search("\n( *)\* ([^\n]*)", end)
                 if(isspace):
                     spacebar = isspace.groups()
                     if(len(spacebar[0]) == 0):
@@ -16,7 +16,7 @@ def indent(data):
                     else:
                         up = len(spacebar[0]) * 20
 
-                    end = re.sub("( *)\*\s([^\n]*)", "<li style='margin-left:" + str(up) + "px'>" + spacebar[1] + "</li>", end, 1)
+                    end = re.sub("\n( *)\* ([^\n]*)", "<li style='margin-left:" + str(up) + "px'>" + spacebar[1] + "</li>", end, 1)
                 else:
                     break
 

+ 1 - 1
set_mark/mark.py

@@ -43,7 +43,7 @@ def namumark(conn, title, data, num, in_c, toc_y):
     data = html_pas.html_pas(data)
     
     fol_num = 0
-    a = mid_pas.mid_pas(data, fol_num, 0, in_c)
+    a = mid_pas.mid_pas(data, fol_num, 0, in_c, toc_y)
     data = a[0]
     fol_num = a[1]
 

+ 11 - 4
set_mark/mid_pas.py

@@ -1,6 +1,6 @@
 import re
 
-def mid_pas(data, fol_num, include, in_c):
+def mid_pas(data, fol_num, include, in_c, toc_y):
     p = re.compile('{{{((?:(?:(?:\+|-)[0-5])|(?:#|@)(?:(?:[0-9a-f-A-F]{3}){1,2}|(?:\w+))|(?:#!(?:html|wiki|noin|folding|syntax)))(?:(?!{{{|}}}).)+)}}}', re.DOTALL)
     while(1):
         m = p.search(data)
@@ -96,9 +96,16 @@ def mid_pas(data, fol_num, include, in_c):
                 data = com.sub(html_d.groups()[0], data, 1)
             elif(fol):
                 fol_d = fol.groups()
-                data = com.sub( "<div>" + fol_d[0] + " <div id='folding_" + str(fol_num + 1) + "' style='display: inline-block;'>[<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>펼치기</a>]</div><div id='folding_" + str(fol_num + 2) + "' style='display: none;'>[<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>접기</a>]</div><div id='folding_" + str(fol_num) + "' style='display: none;'><br>" + fol_d[1] + "</div></div>", data, 1)
-
-                fol_num += 3
+                if(toc_y != 0):
+                    data = com.sub("<div>" + fol_d[0] + " <div id='folding_" + str(fol_num + 1) + "' style='display: inline-block;'>[<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + \
+                                    "); folding(" + str(fol_num + 2) + "); folding(" + str(fol_num) + ");'>펼치기</a>]</div><div id='folding_" + str(fol_num + 2) + \
+                                    "' style='display: none;'>[<a href='javascript:void(0);' onclick='folding(" + str(fol_num + 1) + "); folding(" + str(fol_num + 2) + \
+                                    "); folding(" + str(fol_num) + ");'>접기</a>]</div><div id='folding_" + str(fol_num) + "' style='display: none;'><br>" + fol_d[1] + \
+                                    "</div></div>", data, 1)
+                    fol_num += 3
+                else:
+                    data = com.sub("<div>" + fol_d[0] + "<br><br>" + fol_d[1] + "</div>", data, 1)
+                
             elif(syn):
                 syn_d = syn.groups()
                 tax_d = syn_d[1].replace(' ', '<space>')

+ 2 - 1
set_mark/table.py

@@ -157,7 +157,8 @@ def table(data):
                         table_class = table_d[5]
                         num = table_d[6]
                             
-                        table = re.sub("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", "<table " + table_class + " " + alltable + "><tbody><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
+                        table = re.sub("^(\|\|(?:(?:\|\|)*))((?:&lt;(?:(?:(?!&gt;).)*)&gt;)*)", \
+                                        "<table " + table_class + " " + alltable + "><tbody><tr " + rowstyle + "><td " + cel + " " + row + " " + celstyle + ">", table, 1)
                     else:
                         cel = 'colspan="' + str(round(len(result[0]) / 2)) + '"'