Explorar el Código

목차 들여쓰기

2DU hace 9 años
padre
commit
bb13aeee5d
Se han modificado 4 ficheros con 36 adiciones y 8 borrados
  1. 1 1
      main.py
  2. 23 7
      mark.py
  3. 4 0
      static/style.css
  4. 8 0
      templates/index.html

+ 1 - 1
main.py

@@ -1005,7 +1005,7 @@ def read_view(name = None, redirect = None):
         if(redirect):
             elsedata = re.sub("^#(?:redirect|넘겨주기)\s(?P<in>[^\n]*)", " * [[\g<in>]] 문서로 넘겨주기", elsedata)
         
-        return web_render('index.html', custom = custom_css_user(), license = set_data['license'], login = login_check(), title = name, logo = set_data['name'], page = url_pas(name), data = namumark(name, elsedata) + div, tn = 1, uppage = uppage, style = style, acl = acl, topic = topic, redirect = redirect, admin = admin_memu), 404
+        return web_render('index.html', custom = custom_css_user(), license = set_data['license'], login = login_check(), title = name, logo = set_data['name'], page = url_pas(name), data = namumark(name, elsedata) + div, tn = 1, uppage = uppage, style = style, acl = acl, topic = topic, redirect = redirect, admin = admin_memu, data_none = True), 404
         
 @app.route('/w/<path:name>/r/<int:num>')
 def old_view(name = None, num = None):

+ 23 - 7
mark.py

@@ -318,6 +318,7 @@ def namumark(title, data):
     h4c = 0
     h5c = 0
     last = 0
+    span = ''
     rtoc = '<div id="toc"><span id="toc-name">목차</span><br><br>'
     while(True):
         i = i + 1
@@ -350,26 +351,41 @@ def namumark(title, data):
                 elif(wiki == 5):
                     h5c = 0
             if(wiki == 1):
-                h0c = h0c + 1
+                h0c += 1
             elif(wiki == 2):
-                h1c = h1c + 1
+                h1c += 1
             elif(wiki == 3):
-                h2c = h2c + 1
+                h2c += 1
             elif(wiki == 4):
-                h3c = h3c + 1
+                h3c += 1
             elif(wiki == 5):
-                h4c = h4c + 1
+                h4c += 1
             else:
-                h5c = h5c + 1
+                h5c += 1
 
             toc = str(h0c) + '.' + str(h1c) + '.' + str(h2c) + '.' + str(h3c) + '.' + str(h4c) + '.' + str(h5c) + '.'
+
             toc = re.sub("(?P<in>[0-9]0(?:[0]*)?)\.", '\g<in>#.', toc)
 
             toc = re.sub("0\.", '', toc)
             toc = re.sub("#\.", '.', toc)
             toc = re.sub("\.$", '', toc)
 
-            rtoc = rtoc + '<a href="#s-' + toc + '">' + toc + '</a>. ' + result[1] + '<br>'
+            test = re.search('([0-9]*)(\.([0-9]*))?(\.([0-9]*))?(\.([0-9]*))?(\.([0-9]*))?', toc)
+            if(test):
+                g = test.groups()
+                if(g[4]):
+                    span = '<span id="out"></span>' * 4
+                elif(g[3]):
+                    span = '<span id="out"></span>' * 3
+                elif(g[2]):
+                    span = '<span id="out"></span>' * 2
+                elif(g[1]):
+                    span = '<span id="out"></span>'
+                else:
+                    span = ''
+
+            rtoc = rtoc + span + '<a href="#s-' + toc + '">' + toc + '</a>. ' + result[1] + '<br>'
 
             c = re.sub(" $", "", result[1])
             d = c

+ 4 - 0
static/style.css

@@ -6,6 +6,10 @@
     margin-left: 20px;
 }
 
+#out {
+    margin-left: 5px;
+}
+
 #log {
     line-height: 32px;
     width: 20px;

+ 8 - 0
templates/index.html

@@ -81,11 +81,19 @@
                     <nav class="menu">
                         <a class="menu-item selected" href="#" onclick="return false">{% if sub %}{{sub}}{% elif tn == 1 %}문서{% else %}기타{% endif %}</a>
                         {% if tn == 1 %}
+                        {% if data_none == True %}
+                        <a class="menu-item" href="/edit/{{page}}">생성</a>
+                        {% else %}
                         <a class="menu-item" href="/edit/{{page}}">수정</a>
+                        {% endif %}
                         <a class="menu-item" id="{{topic}}" href="/topic/{{page}}">토론</a>
+                        {% if not data_none == True %}
                         <a class="menu-item" href="/delete/{{page}}">삭제</a>
+                        {% endif %}
                         <a class="menu-item" href="/move/{{page}}">이동</a>
+                        {% if not data_none == True %}
                         <a class="menu-item" href="/raw/{{page}}">Raw</a>
+                        {% endif %}
                         <a class="menu-item" href="/history/{{page}}/n/1">역사</a>
                         <a class="menu-item" href="/backlink/{{page}}/n/1">역링크</a>
                         {% if redirect %}