From 03e2977f129341d28bcfba89f84717cd3ba5a625 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 10 Jul 2019 18:03:23 +0800 Subject: [PATCH] delete mdProcessor --- ahserver/mdProcessor.py | 44 ----------------------------------------- 1 file changed, 44 deletions(-) delete mode 100755 ahserver/mdProcessor.py diff --git a/ahserver/mdProcessor.py b/ahserver/mdProcessor.py deleted file mode 100755 index bd0112e..0000000 --- a/ahserver/mdProcessor.py +++ /dev/null @@ -1,44 +0,0 @@ -import re -from appPublic.jsonConfig import getConfig -from WebServer.configuredResource import BaseProcessor -from WebServer.globalEnv import request2ns,absUrl - -class MarkDownProcessor(BaseProcessor): - @classmethod - def isMe(self,name): - return name=='md' - - content_type='webwidget/json' - - def fileHandle(self,f,request): - b = f.read() - b = self.urlreplace(b,request) - ret = { - "__widget__":"markdown", - "data":{ - "md_text":b - } - } - self.file_data = ret - return self.file_data - - def urlreplace(self,mdtxt,request): - def replaceURL(s): - p1 = '\[.*?\]\((.*?)\)' - url = re.findall(p1,s)[0] - txts = s.split(url) - url = absUrl(request,url) - return url.join(txts) - - p = '\[.*?\]\(.*?\)' - textarray = re.split(p,mdtxt) - links = re.findall(p,mdtxt) - newlinks = [ replaceURL(link) for link in links] - if len(links)>0: - mdtxt = '' - for i in range(len(newlinks)): - mdtxt = mdtxt + textarray[i] - mdtxt = mdtxt + newlinks[i] - mdtxt = mdtxt + textarray[i+1] - return mdtxt -