bugfix
This commit is contained in:
parent
ef186b8d44
commit
8394e18f4e
@ -174,36 +174,13 @@ class MarkdownProcessor(BaseProcessor):
|
|||||||
data = ''
|
data = ''
|
||||||
with codecs.open(self.real_path,'rb','utf-8') as f:
|
with codecs.open(self.real_path,'rb','utf-8') as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
b = data
|
self.content = self.urlreplace(data, request)
|
||||||
b = self.urlreplace(b,request)
|
|
||||||
ret = {
|
|
||||||
"__widget__":"markdown",
|
|
||||||
"data":{
|
|
||||||
"md_text":b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
config = getConfig()
|
|
||||||
self.content = json.dumps(ret,indent=4)
|
|
||||||
|
|
||||||
def urlreplace(self,mdtxt,request):
|
def urlreplace(self,mdtxt,request):
|
||||||
def replaceURL(s):
|
p = '\[(.*)\]\((.*)\)'
|
||||||
p1 = '\[.*?\]\((.*?)\)'
|
return re.sub(p,
|
||||||
url = re.findall(p1,s)[0]
|
lambda x:'['+x.group(1)+'](' + self.resource.entireUrl(request, x.group(2)) + ')',
|
||||||
txts = s.split(url)
|
mdtxt)
|
||||||
url = self.resource.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
|
|
||||||
|
|
||||||
def getProcessor(name):
|
def getProcessor(name):
|
||||||
return _getProcessor(BaseProcessor,name)
|
return _getProcessor(BaseProcessor,name)
|
||||||
|
Loading…
Reference in New Issue
Block a user