You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the dominate python library to create hyperlinks in a text string, but I'm running into an issue where only the first word containing the "@" symbol is being hyperlinked, but then, the rest of the paragraph is omitted.
Here's an example of the function I'm using:
fromdominate.tagsimportp, aimportdominatedefadd_hyperlinks(text):
sentences=text.split('.')
result= []
forsentenceinsentences:
words=sentence.split()
sentence_result= []
forwordinwords:
if"@"inword:
hyperlink=a(word.replace('@', ''), href='http://www.test.com')
sentence_result.append(hyperlink)
else:
sentence_result.append(word)
sentence_result.append(' ')
result.append(p()[:sentence_result])
returnresultstrings= ['Here is a citation to Mr @someone who is a very smart person.',
'I am tryin to do something very difficul with the help of @mrai, I hope that I can make it better than @you, what you think.']
doc=dominate.document(title='Tweeter Report')
withdoc.body:
forstringinstrings:
html=add_hyperlinks(string)
print(str(html))
The text was updated successfully, but these errors were encountered:
Repository owner
locked and limited conversation to collaborators
Mar 3, 2023
I'm trying to use the
dominate
python library to create hyperlinks in a text string, but I'm running into an issue where only the first word containing the "@" symbol is being hyperlinked, but then, the rest of the paragraph is omitted.Here's an example of the function I'm using:
The text was updated successfully, but these errors were encountered: