Răsfoiți Sursa

전체 수정

ect (or 2du) 8 ani în urmă
părinte
comite
47d3550d0b
4 a modificat fișierele cu 126 adăugiri și 162 ștergeri
  1. 21 69
      app.py
  2. 6 6
      func.py
  3. 1 1
      mark.py
  4. 98 86
      set_mark/start.py

+ 21 - 69
app.py

@@ -311,13 +311,11 @@ def edit_set(num = 0):
         li_data = ''
         for li in li_list:
             x += 1
-            li_data += ' * [[wiki:edit_set/' + str(x) + '|' + li + ']]\r\n'
+            li_data += '<li><a href="/edit_set/' + str(x) + '">' + li + '</a></li>'
 
         return html_minify(template('index', 
             imp = ['설정 편집', wiki_set(conn, 1), custom(conn), other2([0, 0])],
-            data = namumark(conn, '',   '[목차(없음)]\r\n' + \
-                                        '== 메뉴 ==\r\n' + \
-                                        li_data, 0, 0, 0),
+            data = '<h2>메뉴</h2><ul>' + li_data + '</ul>',
             menu = [['manager', '관리자']]
         ))
     elif num == 1:
@@ -1216,7 +1214,7 @@ def revert(name = None):
                 
             history_plus(conn, name, data[0][0], today, ip, request.form['send'] + ' (' + str(num) + '판)', leng)
             
-            namumark(conn, name, data[0][0], 1, 0, 0)
+            namumark(conn, name, data[0][0], 1)
             conn.commit()
             
             return redirect('/w/' + url_pas(name))
@@ -1496,9 +1494,12 @@ def edit(name = None):
             curs.execute("insert into alarm (name, data, date) values (?, ?, ?)", [ip, ip + '님이 <a href="/w/' + url_pas(name) + '">' + name + '</a> 문서를 편집 했습니다.', today])
 
         history_plus(conn, name, content, today, ip, send_parser(request.form['send']), leng)
+        
         curs.execute("delete from back where link = ?", [name])
         curs.execute("delete from back where title = ? and type = 'no'", [name])
-        namumark(conn, name, content, 1, 0, 0)
+        
+        namumark(conn, name, content, 1)
+        
         conn.commit()
         
         return redirect('/w/' + url_pas(name))
@@ -1561,12 +1562,11 @@ def preview(name = None):
     if can == 1:
         return re_error(conn, '/ban')
          
-    new_data = request.form['content']
-    new_data = re.sub('\r\n#(?:redirect|넘겨주기) (?P<in>(?:(?!\r\n).)+)\r\n', ' * [[\g<in>]] 문서로 넘겨주기', '\r\n' + new_data + '\r\n')
+    new_data = re.sub('\r\n#(?:redirect|넘겨주기) (?P<in>(?:(?!\r\n).)+)\r\n', ' * [[\g<in>]] 문서로 넘겨주기', '\r\n' + request.form['content'] + '\r\n')
     new_data = re.sub('^\r\n', '', new_data)
     new_data = re.sub('\r\n$', '', new_data)
     
-    end_data = namumark(conn, name, new_data, 0, 0, 1)
+    end_data = namumark(conn, name, new_data, 0)
 
     if request.args.get('section', None):
         action = '?section=' + request.args.get('section', None)
@@ -1714,27 +1714,7 @@ def move(name = None):
 def other():
     return html_minify(template('index', 
         imp = ['기타 메뉴', wiki_set(conn, 1), custom(conn), other2([0, 0])],
-        data = namumark(conn, '', '[목차(없음)]\r\n' + \
-                            '== 기록 ==\r\n' + \
-                            ' * [[wiki:block_log|차단 기록]]\r\n' + \
-                            ' * [[wiki:user_log|가입 기록]]\r\n' + \
-                            ' * [[wiki:admin_log|권한 사용 기록]]\r\n' + \
-                            ' * [[wiki:manager/6|편집 기록]]\r\n' + \
-                            ' * [[wiki:manager/7|토론 기록]]\r\n' + \
-                            '== 목록 ==\r\n' + \
-                            ' * [[wiki:admin_list|관리자 목록]]\r\n' + \
-                            ' * [[wiki:give_log|관리 그룹 목록]]\r\n' + 
-                            ' * [[wiki:not_close_topic|열린 토론 목록]]\r\n' + \
-                            '== 기타 ==\r\n' + \
-                            ' * [[wiki:title_index|모든 문서]]\r\n' + \
-                            ' * [[wiki:acl_list|ACL 문서]]\r\n' + \
-                            ' * [[wiki:please|필요한 문서]]\r\n' + \
-                            ' * [[wiki:upload|파일 올리기]]\r\n' + \
-                            ' * [[wiki:manager/10|문서 검색]]\r\n' + \
-                            '== 관리자 ==\r\n' + \
-                            ' * [[wiki:manager/1|관리자 메뉴]]\r\n' + \
-                            '== 버전 ==\r\n' + \
-                            ' * 이 오픈나무는 [[https://github.com/2DU/openNAMU/blob/master/version.md|' + r_ver + ']] 입니다.', 0, 0, 0),
+        data = '<h2>기록</h2><ul><li><a href="/block_log">차단 기록</a></li><li><a href="/user_log">가입 기록</a></li><li><a href="/admin_log">권한 사용 기록</a></li><li><a href="/manager/6">편집 기록</a></li><li><a href="/manager/7">토론 기록</a></li></ul><br><h2>목록</h2><ul><li><a href="/admin_list">관리자 목록</a></li><li><a href="/give_log">관리 그룹 목록</a></li><li><a href="/not_close_topic">열린 토론 목록</a></li></ul><br><h2>기타</h2><ul><li><a href="/title_index">모든 문서</a></li><li><a href="/acl_list">ACL 문서</a></li><li><a href="/please">필요한 문서</a></li><li><a href="/upload">파일 올리기</a></li><li><a href="/manager/10">문서 검색</a></li></ul><br><h2>관리자</h2><ul><li><a href="/manager/1">관리자 메뉴</a></li></ul><br><h2>버전</h2><ul><li>이 오픈나무는 <a href="https://github.com/2DU/openNAMU/blob/master/version.md">' + r_ver + '</a> 입니다.</li></ul>',
         menu = 0
     ))
     
@@ -1745,22 +1725,7 @@ def manager(num = 1):
     if num == 1:
         return html_minify(template('index', 
             imp = ['관리자 메뉴', wiki_set(conn, 1), custom(conn), other2([0, 0])],
-            data = namumark(conn, '',   '[목차(없음)]\r\n' + \
-                                        '== 목록 ==\r\n' + \
-                                        ' * [[wiki:manager/2|문서 ACL]]\r\n' + \
-                                        ' * [[wiki:manager/3|사용자 검사]]\r\n' + \
-                                        ' * [[wiki:manager/4|사용자 차단]]\r\n' + \
-                                        ' * [[wiki:manager/5|권한 주기]]\r\n' + \
-                                        ' * [[wiki:big_delete|여러 문서 삭제]]\r\n' + \
-                                        ' * [[wiki:edit_filter|편집 필터]]\r\n' + \
-                                        '== 소유자 ==\r\n' + \
-                                        ' * [[wiki:indexing|인덱싱 (생성 or 삭제)]]\r\n' + \
-                                        ' * [[wiki:manager/8|관리 그룹 생성]]\r\n' + \
-                                        ' * [[wiki:edit_set|설정 편집]]\r\n' + \
-                                        ' * [[wiki:re_start|서버 재 시작]]\r\n' + \
-                                        ' * [[wiki:inter_wiki|인터위키]]\r\n' + \
-                                        '== 기타 ==\r\n' + \
-                                        ' * 이 메뉴에 없는 기능은 해당 문서의 역사나 토론에서 바로 사용 가능함', 0, 0, 0),
+            data = '<h2>목록</h2><ul><li><a href="/manager/2">문서 ACL</a></li><li><a href="/manager/3">사용자 검사</a></li><li><a href="/manager/4">사용자 차단</a></li><li><a href="/manager/5">권한 주기</a></li><li><a href="/big_delete">여러 문서 삭제</a></li><li><a href="edit_filter">편집 필터</a></li></ul><br><h2>소유자</h2><ul><li><a href="/indexing">인덱싱 (생성 or 삭제)</a></li><li><a href="/manager/8">관리 그룹 생성</a></li><li><a href="/edit_set">설정 편집</a></li><li><a href="/re_start">서버 재 시작</a></li><li><a href="/inter_wiki">인터위키</a></li></ul>',
             menu = [['other', '기타']]
         ))
     elif num in range(2, 14):
@@ -1993,7 +1958,7 @@ def topic_admin(name = None, sub = None, num = None):
 
     return html_minify(template('index', 
         imp = ['토론 도구', wiki_set(conn, 1), custom(conn), other2([' (' + str(num) + '번)', 0])],
-        data = namumark(conn, '', ban, 0, 0, 0),
+        data = ban,
         menu = [['topic/' + url_pas(name) + '/sub/' + url_pas(sub) + '#' + str(num), '토론']]
     ))
 
@@ -2092,7 +2057,7 @@ def topic(name = None, sub = None):
                                 
             all_data += '<table id="toron"><tbody><tr><td id="toron_color_red">'
             all_data += '<a href="#' + topic_data[1] + '">#' + topic_data[1] + '</a> ' + ip_pas(conn, topic_data[3]) + who_plus + ' <span style="float: right;">' + topic_data[2] + '</span>'
-            all_data += '</td></tr><tr><td>' + namumark(conn, '', topic_data[0], 0, 0, 0) + '</td></tr></tbody></table><br>'    
+            all_data += '</td></tr><tr><td>' + namumark(conn, '', topic_data[0], 0) + '</td></tr></tbody></table><br>'    
 
         for topic_data in topic_1:
             if number == 1:
@@ -2110,7 +2075,7 @@ def topic(name = None, sub = None):
             else:
                 blind_data = ''
 
-            user_write = namumark(conn, '', topic_data[0], 0, 0, 0)
+            user_write = namumark(conn, '', topic_data[0], 0)
             ip = ip_pas(conn, topic_data[3])
 
             curs.execute('select acl from user where id = ?', [topic_data[3]])
@@ -2908,7 +2873,7 @@ def read_view(name = None):
         else_data = re.sub('^\r\n', '', else_data)
         else_data = re.sub('\r\n$', '', else_data)
             
-    end_data = namumark(conn, name, else_data, 0, 0, 1)
+    end_data = namumark(conn, name, else_data, 0)
 
     if data_none == 1:
         menu = [['edit/' + url_pas(name), '생성'], ['topic/' + url_pas(name), topic], ['history/' + url_pas(name), '역사'], ['move/' + url_pas(name), '이동'], ['xref/' + url_pas(name), '역링크']]
@@ -3276,28 +3241,15 @@ def user_info():
             acl += ' (로그인 가능)'
             
     if custom(conn)[2] != 0:
-        ip_user = '[[사용자:' + ip + '|' + ip + ']]'
-        plus = ' * [[wiki:logout|로그아웃]]\r\n * [[wiki:change|비밀번호 변경]]\r\n * [[wiki:email|이메일 수정]]'
+        ip_user = '<a href="/w/사용자:' + ip + '">' + ip + '</a>'
+        plus = '<li><a href="/logout">로그아웃</a></li><li><a href="/change">비밀번호 변경</a></li><li><a href="/email">이메일 수정</a></li>'
     else:
         ip_user = ip
-        plus = ' * [[wiki:login|로그인]]'
+        plus = '<li><a href="/login">로그인</a></li>'
 
     return html_minify(template('index', 
         imp = ['사용자 메뉴', wiki_set(conn, 1), custom(conn), other2([0, 0])],
-        data =  namumark(conn, '',  '[목차(없음)]\r\n' + \
-                                    '== 상태 ==\r\n' + \
-                                    ' * ' + ip_user + ' [[wiki:record/' + url_pas(ip) + '|(기록)]]\r\n' + \
-                                    ' * 권한 상태 : ' + acl + '\r\n' + \
-                                    '== 로그인 ==\r\n' + \
-                                    plus + '\r\n' + \
-                                    ' * [[wiki:register|회원가입]]\r\n' + \
-                                    '== 사용자 기능 ==\r\n' + \
-                                    ' * [[wiki:acl/사용자:' + url_pas(ip) + '|사용자 문서 ACL]]\r\n' + \
-                                    ' * [[wiki:custom_head|사용자 HEAD]]\r\n' + \
-                                    '== 기타 ==\r\n' + \
-                                    ' * [[wiki:alarm|알림]]\r\n' + \
-                                    ' * [[wiki:watch_list|주시 문서]]\r\n' + \
-                                    ' * [[wiki:count|활동 횟수]]\r\n', 0, 0, 0),
+        data =  '<h2>상태</h2><ul><li>' + ip_user + ' <a href="/record/' + url_pas(ip) + '">(기록)</a></li><li>권한 상태 : ' + acl + '</li></ul><br><h2>로그인</h2><ul>' + plus + '<li><a href="/register">회원가입</a></li></ul><br><h2>사용자 기능</h2><ul><li><a href="/acl/사용자:' + url_pas(ip) + '">사용자 문서 ACL</a></li><li><a href="/custom_head">사용자 HEAD</a></li></ul><br><h2>기타</h2><ul><li><a href="/alarm">알림</a></li><li><a href="/watch_list">주시 문서</a></li><li><a href="/count">활동 횟수</a></li></ul>',
         menu = 0
     ))
 
@@ -3440,8 +3392,8 @@ def count_edit(name = None):
 
     return html_minify(template('index', 
         imp = ['활동 횟수', wiki_set(conn, 1), custom(conn), other2([0, 0])],
-        data = namumark(conn, "", "[목차(없음)]\r\n== " + that + " ==\r\n||<:> 편집 횟수 ||<:> " + str(data) + "||\r\n||<:> 토론 횟수 ||<:> " + str(t_data) + "||", 0, 0, 0),
-        menu = [['user', '사용자'], ['record/' + url_pas(that), '편집 기록'], ['topic_record/' + url_pas(that), '토론 기록']]
+        data = '<ul><li><a href="/record/' + url_pas(that) + '">편집 횟수</a> : ' + str(data) + '</li><li><a href="/topic_record/' + url_pas(that) + '">토론 횟수</a> : ' + str(t_data) + '</a></li></ul>',
+        menu = [['user', '사용자']]
     ))
         
 @app.route('/random')

+ 6 - 6
func.py

@@ -399,7 +399,7 @@ def re_error(conn, data):
     curs = conn.cursor()
     if data == '/ban':
         ip = ip_check()
-        end = '|| 사유 || 권한이 맞지 않는 상태 입니다. ||'
+        end = '<li>사유 : 권한이 맞지 않는 상태 입니다.</li>'
         if ban_check(conn) == 1:
             curs.execute("select end, why from ban where block = ?", [ip])
             d = curs.fetchall()
@@ -410,7 +410,7 @@ def re_error(conn, data):
                     d = curs.fetchall()
             
             if d:
-                end = '|| 상태 ||'
+                end = '<li>상태 : '
                 if d[0][0]:
                     now = int(re.sub('(:|-| )', '', get_time()))
                     day = re.sub('\-', '', d[0][0])              
@@ -430,14 +430,14 @@ def re_error(conn, data):
                 else:
                     end += '영구 차단 상태 입니다.'
                 
-                end += '||'
+                end += '</li>'
 
                 if d[0][1] != '':
-                    end += '\r\n|| 사유 || ' + d[0][1] + ' ||'
+                    end += '<li>사유 : ' + d[0][1] + '</li>'
 
         return html_minify(template('index', 
             imp = ['권한 오류', wiki_set(conn, 1), custom(conn), other2([0, 0])],
-            data = namumark(conn, "", "[목차(없음)]\r\n== 권한 상태 ==\r\n" + end, 0, 0, 0),
+            data = '<h2>권한 상태</h2><ul>' + end + '</ul>',
             menu = 0
         ))
 
@@ -517,7 +517,7 @@ def re_error(conn, data):
         if title:
             return html_minify(template('index', 
                 imp = [title, wiki_set(conn, 1), custom(conn), other2([0, 0])],
-                data = namumark(conn, "", "[목차(없음)]\r\n== 오류 발생 ==\r\n" + data, 0, 0, 0),
+                data = '<h2>오류 발생</h2><ul><li>' + data + '</li></ul>',
                 menu = 0
             ))
         else:

+ 1 - 1
mark.py

@@ -24,7 +24,7 @@ def plusing(conn, name, link, backtype):
     if not curs.fetchall():
         curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
 
-def namumark(conn, title, data, num, in_c, toc_y):
+def namumark(conn, title, data, num):
     data = start(conn, data, title)
     
     # if num == 1:        

+ 98 - 86
set_mark/start.py

@@ -111,43 +111,9 @@ def start(conn, data, title):
     curs = conn.cursor()
 
     # 초기 설정
-    data = '\r\n' + data + '\r\n'
-
-    data = re.sub('\r\n( +)\|\|', '\r\n||', data)
-    data = re.sub('\|\|( +)\r\n', '||\r\n', data)
-
-    # XSS 이스케이프
-    data = html.escape(data)
-
-    data = re.sub('&lt;(?P<in>\/?math)&gt;', '<\g<in>>', data)
-
-    while 1:
-        table_back = re.search('\|\|((?:&lt;(?:(?:(?!&gt;)))&gt;)+)', data)
-        if table_back:
-            table_back = table_back.groups()[0]
-
-            table_back = re.sub('&lt;', '<', table_back)
-            table_back = re.sub('&gt;', '>', table_back)
-
-            data = re.sub('\|\|((?:&lt;(?:(?:(?!&gt;)))&gt;)+)', '\|\|' + table_back, data, 1)
-        else:
-            break
-
-    while 1:
-        block_back = re.search('\r\n((?:&gt;)+)', data)
-        if block_back:
-            block_back = block_back.groups()[0]
-            
-            data = re.sub('\r\n((?:&gt;)+)', '\r\n' + ('>' * int(len(block_back) / 4)), data, 1)
-        else:
-            break
-
-    data = re.sub('&#x27;&#x27;&#x27;(?P<in>((?!&#x27;&#x27;&#x27;).)+)&#x27;&#x27;&#x27;', '\'\'\'\g<in>\'\'\'', data)
-    data = re.sub('&#x27;&#x27;(?P<in>((?!&#x27;&#x27;).)+)&#x27;&#x27;', '\'\'\g<in>\'\'', data)
-
-    # 추가 데이터 지정
-    plus_data = ''
+    data = '\n' + data + '\n'
 
+    # 포함 문법 처리
     while 1:
         include = re.search('\[include\(((?:(?!\)\]).)+)\)\]', data)
         if include:
@@ -173,13 +139,14 @@ def start(conn, data, title):
                         include_plus = include_plus.groups()
 
                         include_parser = re.sub('@' + include_plus[0] + '@', include_plus[1], include_parser)
+
                         include = re.sub(', ?((?:(?!=).)+)=((?:(?!,).)+)', '', include, 1)
                     else:
                         break
 
                 include_parser = re.sub('\[\[분류:(((?!\]\]|#include).)+)\]\]', '', include_parser)
 
-                data = re.sub('\[include\(((?:(?!\)\]).)+)\)\]', '\r\n' + include_parser + '\r\n', data, 1)
+                data = re.sub('\[include\(((?:(?!\)\]).)+)\)\]', '\n' + include_parser + '\n', data, 1)
             else:
                 include_link = re.sub('(, ?(?:(?:(?!,).)+))+$', '', include_link)
 
@@ -187,6 +154,45 @@ def start(conn, data, title):
         else:
             break
 
+    # 개행 정리
+    data = re.sub('\r\n', '\n', data)
+
+    # 표 정리
+    data = re.sub('\n( +)\|\|', '\n||', data)
+    data = re.sub('\|\|( +)\n', '||\n', data)
+
+    # XSS 이스케이프
+    data = html.escape(data)
+
+    data = re.sub('&lt;(?P<in>\/?math)&gt;', '<\g<in>>', data)
+
+    while 1:
+        table_back = re.search('\|\|((?:&lt;(?:(?:(?!&gt;).)+)&gt;)+)', data)
+        if table_back:
+            table_back = table_back.groups()[0]
+
+            table_back = re.sub('&lt;', '<', table_back)
+            table_back = re.sub('&gt;', '>', table_back)
+
+            data = re.sub('\|\|((?:&lt;(?:(?:(?!&gt;).)+)&gt;)+)', '||' + table_back, data, 1)
+        else:
+            break
+
+    while 1:
+        block_back = re.search('\n((?:&gt;)+)', data)
+        if block_back:
+            block_back = block_back.groups()[0]
+            
+            data = re.sub('\n((?:&gt;)+)', '\n' + ('>' * int(len(block_back) / 4)), data, 1)
+        else:
+            break
+
+    data = re.sub('&#x27;&#x27;&#x27;(?P<in>((?!&#x27;&#x27;&#x27;).)+)&#x27;&#x27;&#x27;', '\'\'\'\g<in>\'\'\'', data)
+    data = re.sub('&#x27;&#x27;(?P<in>((?!&#x27;&#x27;).)+)&#x27;&#x27;', '\'\'\g<in>\'\'', data)
+
+    # 추가 데이터 지정
+    plus_data = ''
+
     # 수식 처리
     first = 0
     while 1:
@@ -219,23 +225,23 @@ def start(conn, data, title):
     data = re.sub(',,(?P<in>(?:(?!,,).)+),,', '<sub>\g<in></sub>', data)
 
     # 넘겨주기 변환
-    data = re.sub('\r\n#(?:redirect|넘겨주기) (?P<in>(?:(?!\r\n).)+)\r\n', '<meta http-equiv="refresh" content="0; url=/w/\g<in>?froms=' + tool.url_pas(title) + '">', data)
+    data = re.sub('\n#(?:redirect|넘겨주기) (?P<in>(?:(?!\n).)+)\n', '<meta http-equiv="refresh" content="0; url=/w/\g<in>?froms=' + tool.url_pas(title) + '">', data)
 
     # [목차(없음)] 처리
-    if not re.search('\[목차\(없음\)\]\r\n', data):
+    if not re.search('\[목차\(없음\)\]\n', data):
         if not re.search('\[목차\]', data):
-            data = re.sub('\r\n(?P<in>={1,6}) ?(?P<out>(?:(?!=).)+) ?={1,6}\r\n', '\r\n[목차]\r\n\g<in> \g<out> \g<in>\r\n', data, 1)
+            data = re.sub('\n(?P<in>={1,6}) ?(?P<out>(?:(?!=).)+) ?={1,6}\n', '\n[목차]\n\g<in> \g<out> \g<in>\n', data, 1)
     else:
-        data = re.sub('\[목차\(없음\)\]\r\n', '', data)
+        data = re.sub('\[목차\(없음\)\]\n', '', data)
 
     # 문단 문법
     toc_full = 0
     toc_top_stack = 6
     toc_stack = [0, 0, 0, 0, 0, 0]
     edit_number = 0
-    toc_data = '<div id="toc"><span style="font-size: 18px;">목차</span>\r\n\r\n'
+    toc_data = '<div id="toc"><span style="font-size: 18px;">목차</span>\n\n'
     while 1:
-        toc = re.search('\r\n(={1,6}) ?((?:(?!=).)+) ?={1,6}\r\n', data)
+        toc = re.search('\n(={1,6}) ?((?:(?!=).)+) ?={1,6}\n', data)
         if toc:
             toc = toc.groups()
             toc_number = len(toc[0])
@@ -260,9 +266,9 @@ def start(conn, data, title):
 
             all_stack = re.sub('0.', '', all_stack)
             
-            data = re.sub('\r\n(={1,6}) ?((?:(?!=).)+) ?={1,6}\r\n', '\r\n<h' + toc_number + ' id="s-' + re.sub('\.$', '', all_stack) + '"><a href="#toc">' + all_stack + '</a> ' + toc[1] + ' <span style="font-size: 12px"><a href="/edit/' + tool.url_pas(title) + '?section=' + str(edit_number) + '">(편집)</a></span></h' + toc_number + '>\r\n', data, 1)
+            data = re.sub('\n(={1,6}) ?((?:(?!=).)+) ?={1,6}\n', '\n<h' + toc_number + ' id="s-' + re.sub('\.$', '', all_stack) + '"><a href="#toc">' + all_stack + '</a> ' + toc[1] + ' <span style="font-size: 12px"><a href="/edit/' + tool.url_pas(title) + '?section=' + str(edit_number) + '">(편집)</a></span></h' + toc_number + '>\n', data, 1)
 
-            toc_data += '<span style="margin-left: ' + str((toc_full - toc_top_stack) * 10) + 'px;"><a href="#s-' + re.sub('\.$', '', all_stack) + '">' + all_stack + '</a> ' + toc[1] + '</span>\r\n'
+            toc_data += '<span style="margin-left: ' + str((toc_full - toc_top_stack) * 10) + 'px;"><a href="#s-' + re.sub('\.$', '', all_stack) + '">' + all_stack + '</a> ' + toc[1] + '</span>\n'
         else:
             break
 
@@ -271,18 +277,18 @@ def start(conn, data, title):
     data = re.sub('\[목차\]', toc_data, data)
 
     while 1:
-        hr = re.search('\r\n-{4,9}\r\n', data)
+        hr = re.search('\n-{4,9}\n', data)
         if hr:
-            data = re.sub('\r\n-{4,9}\r\n', '\r\n<hr>\r\n', data, 1)
+            data = re.sub('\n-{4,9}\n', '\n<hr>\n', data, 1)
         else:
             break
 
-    data += '\r\n'
+    data += '\n'
 
     # 일부 매크로 처리
     data = tool.savemark(data)
 
-    data = re.sub("\[br\]", '\r\n', data)
+    data = re.sub("\[br\]", '\n', data)
     data = re.sub("\[anchor\((?P<in>(?:(?!\)\]).)+)\)\]", '<span id="\g<in>"></span>', data)          
     data = re.sub("\[nicovideo\((?P<in>(?:(?!,|\)\]).)+)(?:(?:(?!\)\]).)*)\)\]", "[[http://embed.nicovideo.jp/watch/\g<in>|\g<in>]]", data)
     data = re.sub('\[ruby\((?P<in>(?:(?!,).)+)\, ?(?P<out>(?:(?!\)\]).)+)\)\]', '<ruby>\g<in><rp>(</rp><rt>\g<out></rt><rp>)</rp></ruby>', data)
@@ -359,26 +365,26 @@ def start(conn, data, title):
 
     # 인용문 구현
     while 1:
-        block = re.search('(\r\n(?:> ?(?:(?:(?!\r\n).)+)\r\n)+)', data)
+        block = re.search('(\n(?:> ?(?:(?:(?!\n).)+)\n)+)', data)
         if block:
             block = block.groups()[0]
 
-            block = re.sub('^\r\n> ?', '', block)
-            block = re.sub('\r\n> ?', '\r\n', block)
-            block = re.sub('\r\n$', '', block)
+            block = re.sub('^\n> ?', '', block)
+            block = re.sub('\n> ?', '\n', block)
+            block = re.sub('\n$', '', block)
 
-            data = re.sub('(\r\n(?:> ?(?:(?:(?!\r\n).)+)\r\n)+)', '<blockquote>' + block + '</blockquote>\r\n', data, 1)
+            data = re.sub('(\n(?:> ?(?:(?:(?!\n).)+)\n)+)', '<blockquote>' + block + '</blockquote>\n', data, 1)
         else:
             break
 
     # 리스트 구현
     while 1:
-        li = re.search('(\r\n(?:(?: *)\* ?(?:(?:(?!\r\n).)+)\r\n)+)', data)
+        li = re.search('(\n(?:(?: *)\* ?(?:(?:(?!\n).)+)\n)+)', data)
         if li:
             li = li.groups()[0]
 
             while 1:
-                sub_li = re.search('\r\n(?:( *)\* ?((?:(?!\r\n).)+))', li)
+                sub_li = re.search('\n(?:( *)\* ?((?:(?!\n).)+))', li)
                 if sub_li:
                     sub_li = sub_li.groups()
 
@@ -388,30 +394,30 @@ def start(conn, data, title):
                     else:
                         margin = len(sub_li[0]) * 20
 
-                    li = re.sub('\r\n(?:( *)\* ?((?:(?!\r\n).)+))', '<li style="margin-left: ' + str(margin) + 'px;">' + sub_li[1] + '</li>', li, 1)
+                    li = re.sub('\n(?:( *)\* ?((?:(?!\n).)+))', '<li style="margin-left: ' + str(margin) + 'px;">' + sub_li[1] + '</li>', li, 1)
                 else:
                     break
 
-            data = re.sub('(\r\n(?:(?: *)\* ?(?:(?:(?!\r\n).)+)\r\n)+)', '\r\n\r\n<ul>' + li + '</ul>\r\n', data, 1)
+            data = re.sub('(\n(?:(?: *)\* ?(?:(?:(?!\n).)+)\n)+)', '\n\n<ul>' + li + '</ul>', data, 1)
         else:
             break
 
     # 들여쓰기 구현
     while 1:
-        indent = re.search('\r\n( +)', data)
+        indent = re.search('\n( +)', data)
         if indent:
             indent = len(indent.groups()[0])
             
             # 앞에 공백 만큼 margin 먹임
             margin = '<span style="margin-left: 20px;"></span>' * indent
 
-            data = re.sub('\r\n( +)', '\r\n' + margin, data, 1)
+            data = re.sub('\n( +)', '\n' + margin, data, 1)
         else:
             break
 
     # 표 처리
     while 1:
-        table = re.search('\r\n((?:(?:(?:(?:\|\|)+(?:(?:(?!\|\|).(?:\r\n)*)+))+)\|\|(?:\r\n)?)+)', data)
+        table = re.search('\n((?:(?:(?:(?:\|\|)+(?:(?:(?!\|\|).(?:\n)*)+))+)\|\|(?:\n)?)+)', data)
         if table:
             table = table.groups()[0]
             
@@ -424,20 +430,20 @@ def start(conn, data, title):
                     return_table = table_parser(all_table[1], all_table[2], all_table[0])
                     number = return_table[6]
 
-                    table = re.sub('^\|\|((?:<(?:(?:(?!>).)+)>)*)', '\r\n<table ' + return_table[5] + ' ' + return_table[0] + '><tbody><tr ' + return_table[1] + '><td ' + return_table[2] + ' ' + return_table[3] + ' ' + return_table[4] + '>\r\n', table, 1)
+                    table = re.sub('^\|\|((?:<(?:(?:(?!>).)+)>)*)', '\n<table ' + return_table[5] + ' ' + return_table[0] + '><tbody><tr ' + return_table[1] + '><td ' + return_table[2] + ' ' + return_table[3] + ' ' + return_table[4] + '>\n', table, 1)
                 else:
                     break
 
-            table = re.sub('\|\|\r\n$', '</td></tr></tbody></table>', table)
+            table = re.sub('\|\|\n$', '</td></tr></tbody></table>', table)
 
             while 1:
-                row_table = re.search('\|\|\r\n((?:\|\|)+)((?:<(?:(?:(?!>).)+)>)*)((?:(?!\|\||<\/td>).)+)', table)
+                row_table = re.search('\|\|\n((?:\|\|)+)((?:<(?:(?:(?!>).)+)>)*)((?:(?!\|\||<\/td>).)+)', table)
                 if row_table:
                     row_table = row_table.groups()
 
                     return_table = table_parser(row_table[1], row_table[2], row_table[0], number)
 
-                    table = re.sub('\|\|\r\n((?:\|\|)+)((?:<(?:(?:(?!>).)+)>)*)', '</td></tr><tr ' + return_table[1] + '><td ' + return_table[2] + ' ' + return_table[3] + ' ' + return_table[4] + '>', table, 1)
+                    table = re.sub('\|\|\n((?:\|\|)+)((?:<(?:(?:(?!>).)+)>)*)', '</td></tr><tr ' + return_table[1] + '><td ' + return_table[2] + ' ' + return_table[3] + ' ' + return_table[4] + '>', table, 1)
                 else:
                     break
 
@@ -446,18 +452,18 @@ def start(conn, data, title):
                 if cel_table:
                     cel_table = cel_table.groups()
 
-                    return_table = table_parser(cel_table[1], re.sub('\r\n', ' ', cel_table[2]), cel_table[0], number)
+                    return_table = table_parser(cel_table[1], re.sub('\n', ' ', cel_table[2]), cel_table[0], number)
 
                     table = re.sub('((?:\|\|)+)((?:<(?:(?:(?!>).)+)>)*)', '</td><td ' + return_table[2] + ' ' + return_table[3] + ' ' + return_table[4] + '>', table, 1)
                 else:
                     break
 
-            data = re.sub('\r\n((?:(?:(?:(?:\|\|)+(?:(?:(?!\|\|).(?:\r\n)*)+))+)\|\|(?:\r\n)?)+)', table, data, 1)
+            data = re.sub('\n((?:(?:(?:(?:\|\|)+(?:(?:(?!\|\|).(?:\n)*)+))+)\|\|(?:\n)?)+)', table, data, 1)
         else:
             break
 
     # 링크 관련 문법 구현
-    category = '\r\n<div id="cate">분류: '
+    category = '\n<hr><div id="cate">분류: '
     while 1:
         link = re.search('\[\[((?:(?!\[\[|\]\]).)+)\]\]', data)
         if link:
@@ -550,9 +556,10 @@ def start(conn, data, title):
 
     # 각주 처리
     footnote_number = 0
-    footnote_all = '\r\n<hr><ul id="footnote_data">'
+    footnote_all = '\n<hr><ul id="footnote_data">'
+    footnote_dict = {}
     while 1:
-        footnote = re.search('(?:\[\*((?:(?! ).)*) ((?:(?!\]).)+)\]|(\[각주\]))', data)
+        footnote = re.search('(?:\[\*((?:(?! |\]).)*)(?: ((?:(?!\]).)+))?\]|(\[각주\]))', data)
         if footnote:
             footnote_data = footnote.groups()
 
@@ -561,46 +568,51 @@ def start(conn, data, title):
 
                 data = re.sub('(?:\[\*((?:(?! ).)*) ((?:(?!\]).)+)\]|(\[각주\]))', footnote_all, data, 1)
 
-                footnote_all = '\r\n<hr><ul id="footnote_data">'
+                footnote_all = '\n<hr><ul id="footnote_data">'
             else:
                 footnote = footnote_data[1]
                 footnote_name = footnote_data[0]
 
-                footnote_number += 1
+                if footnote_name and not footnote:
+                    data = re.sub('(?:\[\*((?:(?! |\]).)*)(?: ((?:(?!\]).)+))?\]|(\[각주\]))', '<sup><a href="#fn-' + footnote_dict[footnote_name] + '" id="rfn-' + footnote_dict[footnote_name] + '">(' + footnote_name + ')</a></sup>', data, 1)
+                else:
+                    footnote_number += 1
 
-                if not footnote_name:
-                    footnote_name = str(footnote_number)
+                    if not footnote_name:
+                        footnote_name = str(footnote_number)
+                    else:
+                        footnote_dict.update({ footnote_name : str(footnote_number) })
 
-                footnote_all += '<li><a href="#rfn-' + str(footnote_number) + '" id="fn-' + str(footnote_number) + '">(' + footnote_name + ')</a> ' + footnote + '</li>'
+                    footnote_all += '<li><a href="#rfn-' + str(footnote_number) + '" id="fn-' + str(footnote_number) + '">(' + footnote_name + ')</a> ' + footnote + '</li>'
 
-                data = re.sub('(?:\[\*((?:(?! ).)*) ((?:(?!\]).)+)\]|(\[각주\]))', '<sup><a href="#fn-' + str(footnote_number) + '" id="rfn-' + str(footnote_number) + '">(' + footnote_name + ')</a></sup>', data, 1)
+                    data = re.sub('(?:\[\*((?:(?! |\]).)*)(?: ((?:(?!\]).)+))?\]|(\[각주\]))', '<sup><a href="#fn-' + str(footnote_number) + '" id="rfn-' + str(footnote_number) + '">(' + footnote_name + ')</a></sup>', data, 1)
         else:
             break
 
     footnote_all += '</ul>'
 
-    if footnote_all == '\r\n<hr><ul id="footnote_data"></ul>':
+    if footnote_all == '\n<hr><ul id="footnote_data"></ul>':
         footnote_all = ''
 
-    data = re.sub('\r\n$', footnote_all, data)
+    data = re.sub('\n$', footnote_all, data, 1)
 
     # 분류 마지막 처리
     category += '</div>'
     category = re.sub(' / <\/div>$', '</div>', category)
 
-    if category == '\r\n<div id="cate">분류: </div>':
+    if category == '\n<hr><div id="cate">분류: </div>':
         category = ''
 
     data += category
     
     # 마지막 처리
-    data = re.sub('(?P<in><\/h[0-9]>)(\r\n)+', '\g<in>', data)
-    data = re.sub('<\/ul>\r\n\r\n', '</ul>\r\n', data)
-    data = re.sub('^(\r\n)+', '', data)
-    data = re.sub('(\r\n)+<hr><ul id="footnote_data">', '<hr><ul id="footnote_data">', data)
-    data = re.sub('(?P<in><td(((?!>).)*)>)\r\n', '\g<in>', data)
-    data = re.sub('(\r\n)?<hr>(\r\n)?', '<hr>', data)
-    data = re.sub('\r\n', '<br>', data)
+    data = re.sub('(?P<in><\/h[0-9]>)(\n)+', '\g<in>', data)
+    data = re.sub('<\/ul>\n\n', '</ul>\n', data)
+    data = re.sub('^(\n)+', '', data)
+    data = re.sub('(\n)+<hr><ul id="footnote_data">', '<hr><ul id="footnote_data">', data)
+    data = re.sub('(?P<in><td(((?!>).)*)>)\n', '\g<in>', data)
+    data = re.sub('(\n)?<hr>(\n)?', '<hr>', data)
+    data = re.sub('\n', '<br>', data)
 
     if data == '':
         data = '문서가 없습니다.'