Support markdown format links

main
Bob Mottram 2021-02-24 14:41:46 +00:00
parent e75e35fc22
commit 6a93f8d9a8
1 changed files with 31 additions and 11 deletions

View File

@ -176,22 +176,42 @@ def getLeftColumnContent(baseDir: str, nickname: str, domainFull: str,
if ' ' not in lineStr: if ' ' not in lineStr:
if '#' not in lineStr: if '#' not in lineStr:
if '*' not in lineStr: if '*' not in lineStr:
if not lineStr.startswith('=> '): if not lineStr.startswith('['):
continue if not lineStr.startswith('=> '):
continue
lineStr = lineStr.strip() lineStr = lineStr.strip()
words = lineStr.split(' ')
# get the link
linkStr = None linkStr = None
for word in words: if not lineStr.startswith('['):
if word == '#': words = lineStr.split(' ')
# get the link
for word in words:
if word == '#':
continue
if word == '*':
continue
if word == '=>':
continue
if '://' in word:
linkStr = word
break
else:
# markdown link
if ']' not in lineStr:
continue continue
if word == '*': if '(' not in lineStr:
continue continue
if word == '=>': if ')' not in lineStr:
continue continue
if '://' in word: linkStr = lineStr.split('(')[1]
linkStr = word if ')' not in linkStr:
break continue
linkStr = linkStr.split(')')[0]
if '://' not in linkStr:
continue
lineStr = lineStr.split('[')[1]
if ']' not in lineStr:
continue
lineStr = lineStr.split(']')[0]
if linkStr: if linkStr:
lineStr = lineStr.replace(linkStr, '').strip() lineStr = lineStr.replace(linkStr, '').strip()
# avoid any dubious scripts being added # avoid any dubious scripts being added