Переглянути джерело

코드 하다 날라가서 새로 짬

근데 이거 맞는지 모르겠음
2DU 9 роки тому
батько
коміт
0bdec61646
2 змінених файлів з 10 додано та 2 видалено
  1. 6 2
      app.py
  2. 4 0
      static/style.css

+ 6 - 2
app.py

@@ -109,6 +109,10 @@ def show_diff(seqm):
             output.append("<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span>")
         elif(opcode == 'delete'):
             output.append("<span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>")
+        elif(opcode == 'replace'):
+            output.append("<span style='background:#CFC;'>" + seqm.b[b0:b1] + "</span><span style='background:#FDD;'>" + seqm.a[a0:a1] + "</span>")
+        else:
+            output.append(seqm.a[a0:a1])
     return ''.join(output)
            
 def admincheck():
@@ -3429,16 +3433,16 @@ def diff(name = None, a = None, b = None):
             indata = re.sub('<', '&lt;', rows[0]['data'])
             indata = re.sub('>', '&gt;', indata)
             indata = re.sub('"', '&quot;', indata)
-            indata = re.sub('\n', '<br>', indata)
             
             enddata = re.sub('<', '&lt;', row[0]['data'])
             enddata = re.sub('>', '&gt;', enddata)
             enddata = re.sub('"', '&quot;', enddata)
-            enddata = re.sub('\n', '<br>', enddata)
             
             sm = difflib.SequenceMatcher(None, indata, enddata)
             c = show_diff(sm)
             
+            c = '<pre>' + c + '</pre>'
+            
             return render_template('index.html', title = name, logo = data['name'], data = c, sub = '비교')
         else:
             return '<meta http-equiv="refresh" content="0;url=/history/' + parse.quote(name).replace('/','%2F') + '" />'

+ 4 - 0
static/style.css

@@ -474,4 +474,8 @@ a.not_thing {
 
 sub, sup {
     line-height: 1.4em;
+}
+
+pre span {
+    font-family: '니눔고딕코딩', 'Nanum Gothic Coding', monospace;
 }