Closed MikeJLeon closed 5 years ago
Good work @daonguyen81 it add the anchors as expected now.
Time spent: 2 hrs. Anchor tag added
url = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+] |[!*\(\), ]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', row.text)
if url:
for word in row.text.split():
if 'http' in word:
link_url = '<a href="{}"'.format(word) + ' target="{}"><strong>'.format('_blank') + word + '</strong></a>'
p_desc = p_desc + link_url + " "
else:
p_desc = p_desc + word + " "
else:
p_desc = p_desc + row.text
if row.findAll("a"):
for link in row.findAll("a"):
if link.has_attr('href'):
link_url = '<a href="{}"'.format(link['href']) + ' target="{}"><strong>'.format('_blank') + link.text + '</strong></a>'
if link.text in p_desc:
p_desc = p_desc.replace(link.text, link_url)
After getting feedback from Erik, I would like you to help me with my code to just check the description data and ensure if any links are present in the data then to add or retain the anchor tags so that they appear properly in the UI