devtools/hackdoc: propagate ref in imgs and redirects
Change-Id: Ideb2a8f10f8193cd782b0e1d913e7aa99bbfa52f
diff --git a/devtools/hackdoc/main.go b/devtools/hackdoc/main.go
index aae850f..e460721 100644
--- a/devtools/hackdoc/main.go
+++ b/devtools/hackdoc/main.go
@@ -205,7 +205,7 @@
}
if file {
- http.Redirect(r.w, r.r, "/"+fpath, 302)
+ http.Redirect(r.w, r.r, "/"+fpath+"?ref="+r.ref, 302)
return
}
}
diff --git a/devtools/hackdoc/markdown.go b/devtools/hackdoc/markdown.go
index 06e2c6e..14ffe45 100644
--- a/devtools/hackdoc/markdown.go
+++ b/devtools/hackdoc/markdown.go
@@ -27,7 +27,7 @@
r.RenderHeader(&buf, ast)
buf.Write([]byte(`</div><div class="content">`))
ast.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus {
- if ref != "" && entering && node.Type == blackfriday.Link {
+ if ref != "" && entering && node.Type == blackfriday.Link || node.Type == blackfriday.Image {
dest := string(node.Destination)
u, err := url.Parse(dest)
if err == nil && !u.IsAbs() {