go.tools/present: Open links with local (non absolute) URLs in the same window.
This allows having links from one slide to another one in the same presentation. Also it is needed in the new tour to cross reference lessons. R=r CC=golang-codereviews https://golang.org/cl/46130043
This commit is contained in:
parent
30645c4bc6
commit
3d2d158b9d
|
|
@ -45,7 +45,13 @@ func renderLink(url, text string) string {
|
|||
if text == "" {
|
||||
text = url
|
||||
}
|
||||
return fmt.Sprintf(`<a href="%s" target="_blank">%s</a>`, url, text)
|
||||
// Open links in new window only when their url is absolute.
|
||||
target := "_blank"
|
||||
if url[0] == '/' {
|
||||
target = "_self"
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`<a href="%s" target="%s">%s</a>`, url, target, text)
|
||||
}
|
||||
|
||||
// parseInlineLink parses an inline link at the start of s, and returns
|
||||
|
|
|
|||
Loading…
Reference in New Issue