Search code examples
htmlprefix

Mass prefix and subfix


Input data:

Text 1
Text 2
Etc...

I want a output like this. Would prefer a .txt file

<a target="_blank" href="https://www.website.com/Text 1">Text 1</a>
<a target="_blank" href="https://www.website.com/Text 2">Text 2</a>

Prefix is:

<a target="_blank" href="https://www.website.com/"></a>

Can someone help me?


Solution

  • Based on you comment, you need to learn about scripting...

    e.g. with python you can do:

    #!python3
    inputext = """Text 1
    Text 2
    Etc..."""
    
    outputext = ''
    for line in inputext.split('\n'):
        outputext += "<a target=\"_blank\" href=\"https://www.website.com/" + line + "\">" + line + "</a>\n"
    with open('outfilepath.html', 'w') as outfile:
        outfile.write(outputext)