0

I'm new to web development, any help from the forum really appreciated!!

I'm reading the text from multiple text files and sending it to a html form as a list.

The text may have some links. These links are not enabled when it is diplayed as a paragraph. I cannot read each file and put href attributs where ever a link present.

So need help in making below snip enable a link.

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading </h1>
<pre>My first paragraph. https://www.w3schools.com/html/tryit.asp?filename=tryhtml_elements</pre>

</body>
</html>
Vhota
  • 11
  • 2

1 Answers1

0

I cannot read each file and put href attributs where ever a link present.

Back up your text files first and consider using sed from the command line to experiment with automatically adding html to the links within each txt file:

sed -i -e "s|http[:]//[^ ]*|<a href=\"\0\">\0</a>|g" yourfile.txt [1]

In the above example, yourfile would be replaced with the name of the text file you're working with. If the results look promising, you could update the sed command to modify all txt files in a specific location.

Good luck.


[1] Convert URLs into HTML links using sed?

Will Binns
  • 57
  • 9