diff --git a/content.py b/content.py index a3fa40e2..caabb179 100644 --- a/content.py +++ b/content.py @@ -10,6 +10,29 @@ import os import commentjson from shutil import copyfile +def addWebLinks(content: str) -> str: + """Adds markup for web links + """ + if not ('https://' in content or 'http://' in content): + return content + + words=content.split(' ') + replaceDict={} + for w in words: + if w.startswith('http://') or w.startswith('http://'): + if w.endswith('.') or w.endswith(';'): + w=w[:-1] + markup='' + if w.startswith('https://'): + markup+='' + elif w.startswith('http://'): + markup+='' + markup+=''+w.replace('https://','').replace('http://','')+'' + replaceDict[w]=markup + for url,markup in replaceDict.items(): + content=content.replace(url,markup) + return content + def validHashTag(hashtag: str) -> bool: """Returns true if the give hashtag contains valid characters """ @@ -221,6 +244,7 @@ def addHtmlTags(baseDir: str,httpPrefix: str, \ content=content.replace(wordStr,replaceStr) content=content.replace('\n','

') + content=addWebLinks(content) return '

'+content+'

' def getMentionsFromHtml(htmlText: str,matchStr=" []: