From be2596471f352c41b02a57e96c963d16ecb56183 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Mon, 14 Jan 2013 09:35:04 +1100 Subject: [PATCH] cmd/godoc: support m=text parameter for text files It's possible to view the package docs in plain text, eg: http://golang.org/pkg/time/?m=text and this CL introduces the ability to do the same for files: http://golang.org/src/pkg/time/time.go?m=text R=golang-dev, dave, minux.ma CC=golang-dev https://golang.org/cl/7085054 --- src/cmd/godoc/godoc.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go index e2d489c581..12148ec1cd 100644 --- a/src/cmd/godoc/godoc.go +++ b/src/cmd/godoc/godoc.go @@ -15,6 +15,7 @@ import ( "go/format" "go/printer" "go/token" + htmlpkg "html" "io" "io/ioutil" "log" @@ -681,10 +682,16 @@ func serveTextFile(w http.ResponseWriter, r *http.Request, abspath, relpath, tit return } + if r.FormValue("m") == "text" { + serveText(w, src) + return + } + var buf bytes.Buffer buf.WriteString("
")
 	FormatText(&buf, src, 1, pathpkg.Ext(abspath) == ".go", r.FormValue("h"), rangeSelection(r.FormValue("s")))
 	buf.WriteString("
") + fmt.Fprintf(&buf, `

View as plain text

`, htmlpkg.EscapeString(relpath)) servePage(w, Page{ Title: title + " " + relpath, -- 2.48.1