Skip to content

Way to insert links that open in new tab #11

@sbarratt

Description

@sbarratt

I've made it so that if you start a link with \/, it opens it in a new tab. I've done this by adding the lines

    if link[:2] == '\\/':
      link = link[2:]
      newtab = True
    else:
      newtab = False

and then the lines

    if not newtab:
      b = b[:m.start()] + r'<a href=\"%s\">%s<\/a>' % (link, linkname) + b[m.end():]
    else:
      b = b[:m.start()] + r'<a rel=\"noopener noreferrer\" target=\"_blank\" href=\"%s\">%s<\/a>' % (link, linkname) + b[m.end():]

to the replacelinks function which seems to work well.

What do you think about adding this to master? What would be a good way to signify new tab?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions