2
0
2DU 9 жил өмнө
parent
commit
9effa10dbe
1 өөрчлөгдсөн 9 нэмэгдсэн , 30 устгасан
  1. 9 30
      app.py

+ 9 - 30
app.py

@@ -133,6 +133,8 @@ def namumark(title, data):
     
     data = re.sub("\[목차\]", rtoc, data)
     
+    data = re.sub("\[\[분류:(((?!\]\]).)*)\]\]", '', data)
+    
     while True:
         m = re.search("{{{((?:(?!{{{)(?!}}}).)*)}}}", data)
         if(m):
@@ -259,7 +261,6 @@ def namumark(title, data):
                     if(c):
                         img = result[0]
                         img = re.sub("\.(?P<in>jpg|png|gif|jpeg)", "#\g<in>#", img)
-                        print('<a class="out_link" href="' + img + '">' + result[0] + '</a>')
                         data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + img + '">' + result[0] + '</a>', data, 1)
                     else:
                         data = re.sub('\[\[(((?!\]\]).)*)\]\]', '<a class="out_link" href="' + result[0] + '">' + result[0] + '</a>', data, 1)
@@ -287,32 +288,6 @@ def namumark(title, data):
         else:
             break
     
-    while True:
-        m = re.search("(http(?:s)?:\/\/(?:(?:(?!\.jpg|\.png|\.gif|\.jpeg|#jpg#|#png#|#gif#|#jpeg#).)*)(?:\.jpg|\.png|\.gif|\.jpeg))(?:\?([^ \n]*))?", data)
-        if(m):
-            c = m.groups()
-            print(c)
-            if(c[1]):
-                n = re.search("width=([^ \n&]*)", c[1])
-                e = re.search("height=([^ \n&]*)", c[1])
-                if(n):
-                    a = n.groups()
-                    width = a[0]
-                else:
-                    width = ''
-                if(e):
-                    b = e.groups()
-                    height = b[0]
-                else:
-                    height = ''
-                img = re.sub("\.(?P<in>jpg|png|gif|jpeg)", "#\g<in>#", c[0])
-                data = re.sub('(http(?:s)?:\/\/(?:(?:(?!\.jpg|\.png|\.gif|\.jpeg|#jpg#|#png#|#gif#|#jpeg#).)*)(?:\.jpg|\.png|\.gif|\.jpeg))(?:\?([^ \n]*))?', '<img src="' + img + '" style="width:' + width + ';height:' + height + ';">', data, 1)
-            else:
-                img = re.sub("\.(?P<in>jpg|png|gif|jpeg)", "#\g<in>#", c[0])
-                data = re.sub('(http(?:s)?:\/\/(?:(?:(?!\.jpg|\.png|\.gif|\.jpeg|#jpg#|#png#|#gif#|#jpeg#).)*)(?:\.jpg|\.png|\.gif|\.jpeg))(?:\?([^ \n]*))?', '<img src="' + img + '">', data, 1)
-        else:
-            break
-    
     data = re.sub('\[date\]', getnow(), data)
     data = re.sub("\[anchor\((?P<in>[^\[\]]*)\)\]", '<span id="\g<in>"></span>', data)
     
@@ -339,15 +314,19 @@ def namumark(title, data):
     a = 1
     tou = "<hr id='footnote'><div class='wiki-macro-footnote'><br>"
     while True:
-        b = re.search("\[\*([^\s]*)\s((?:[^\[\]]+)*)\]", data)
+        b = re.search("\[\*([^\s]*)\s(((?!\]).)*)\]", data)
         if(b):
             results = b.groups()
             if(results[0]):
+                c = results[1]
+                c = re.sub("<(?:[^>]*)>", '', c)
                 tou = tou + "<span class='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + results[0] + "]</a> " + results[1] + "</span><br>"
-                data = re.sub("\[\*([^\s]*)\s((?:[^\[\]]+)*)\]", "<sup><a class=\"footnotes\" title=\"" + results[1] + "\" id=\"rfn-" + str(a) + "\" href=\"#fn-" + str(a) + "\">[" + results[0] + "]</a></sup>", data, 1)
+                data = re.sub("\[\*([^\s]*)\s(((?!\]).)*)\]", "<sup><a class=\"footnotes\" title=\"" + c + "\" id=\"rfn-" + str(a) + "\" href=\"#fn-" + str(a) + "\">[" + results[0] + "]</a></sup>", data, 1)
             else:
+                c = results[1]
+                c = re.sub("<(?:[^>]*)>", '', c)
                 tou = tou + "<span class='footnote-list'><a href=\"#rfn-" + str(a) + "\" id=\"fn-" + str(a) + "\">[" + str(a) + "]</a> " + results[1] + "</span><br>"
-                data = re.sub("\[\*([^\s]*)\s((?:[^\[\]]+)*)\]", '<sup><a class="footnotes" title="' + results[1] + '" id="rfn-' + str(a) + '" href="#fn-' + str(a) + '">[' + str(a) + ']</a></sup>', data, 1)
+                data = re.sub("\[\*([^\s]*)\s(((?!\]).)*)\]", '<sup><a class="footnotes" title="' + c + '" id="rfn-' + str(a) + '" href="#fn-' + str(a) + '">[' + str(a) + ']</a></sup>', data, 1)
             a = a + 1
         else:
             tou = tou + '</div>'