From 3d2d158b9d69bbd99755db3343ed863a00516f4d Mon Sep 17 00:00:00 2001 From: Francesc Campoy Date: Sat, 28 Dec 2013 21:10:40 -0800 Subject: [PATCH] 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 --- present/link.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/present/link.go b/present/link.go index a840b23d..813344c6 100644 --- a/present/link.go +++ b/present/link.go @@ -45,7 +45,13 @@ func renderLink(url, text string) string { if text == "" { text = url } - return fmt.Sprintf(`%s`, url, text) + // Open links in new window only when their url is absolute. + target := "_blank" + if url[0] == '/' { + target = "_self" + } + + return fmt.Sprintf(`%s`, url, target, text) } // parseInlineLink parses an inline link at the start of s, and returns