diff --git a/content.py b/content.py index 081f53da2..50f8b5e8c 100644 --- a/content.py +++ b/content.py @@ -16,7 +16,7 @@ def addWebLinks(content: str) -> str: if not ('https://' in content or 'http://' in content): return content - words=content.split(' ') + words=content.replace('\n',' --linebreak--').split(' ') replaceDict={} for w in words: if w.startswith('https://') or w.startswith('http://'): @@ -31,6 +31,7 @@ def addWebLinks(content: str) -> str: replaceDict[w]=markup for url,markup in replaceDict.items(): content=content.replace(url,markup) + content=content.replace(' --linebreak--','
') return content def validHashTag(hashtag: str) -> bool: diff --git a/tests.py b/tests.py index cf2ccc1e7..e06dec028 100644 --- a/tests.py +++ b/tests.py @@ -64,6 +64,7 @@ from media import getAttachmentMediaType from delete import sendDeleteViaServer from inbox import validInbox from inbox import validInboxFilenames +from content import addWebLinks testServerAliceRunning = False testServerBobRunning = False @@ -1368,8 +1369,15 @@ def testActorParsing(): nickname=getNicknameFromActor(actor) assert nickname=='othernick' +def testWebLinks(): + exampleText='This post has a web links https://somesite.net\n\nAnd some other text' + linkedText=addWebLinks(exampleText) + print(exampleText) + print(linkedText) + def runAllTests(): print('Running tests...') + testWebLinks() testActorParsing() testHttpsig() testCache()