main2
Bob Mottram 2019-10-09 13:23:20 +01:00
parent de2b62ab5f
commit 4736d144f4
1 changed files with 4 additions and 3 deletions

View File

@ -59,6 +59,7 @@ def addWebLinks(content: str) -> str:
if not ('https://' in content or 'http://' in content): if not ('https://' in content or 'http://' in content):
return content return content
maxLinkLength=40
words=content.replace('\n',' --linebreak-- ').split(' ') words=content.replace('\n',' --linebreak-- ').split(' ')
replaceDict={} replaceDict={}
for w in words: for w in words:
@ -76,9 +77,9 @@ def addWebLinks(content: str) -> str:
markup+='<span class="invisible">dat://</span>' markup+='<span class="invisible">dat://</span>'
linkText=w.replace('https://','').replace('http://','').replace('dat://','') linkText=w.replace('https://','').replace('http://','').replace('dat://','')
# prevent links from becoming too long # prevent links from becoming too long
if len(linkText)>40: if len(linkText)>maxLinkLength:
markup+='<span class="ellipsis">'+linkText[:40]+'</span>' markup+='<span class="ellipsis">'+linkText[:maxLinkLength]+'</span>'
markup+='<span class="invisible">'+linkText[40:]+'</span></a>' markup+='<span class="invisible">'+linkText[maxLinkLength:]+'</span></a>'
else: else:
markup+='<span class="ellipsis">'+linkText+'</span></a>' markup+='<span class="ellipsis">'+linkText+'</span></a>'
replaceDict[w]=markup replaceDict[w]=markup