From f2d8c9a57d8c237be55c1913080fdbd2ec4e9126 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 11 Aug 2018 11:04:43 +0100 Subject: [PATCH] html: Allow additional head bytes to be injected Allows one to add more head tags, mostly scripts usually, to be included in the section of the generated HTML. This keeps the doc self contained. Signed-off-by: Miek Gieben --- html/renderer.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/html/renderer.go b/html/renderer.go index a34290f..97d4c92 100644 --- a/html/renderer.go +++ b/html/renderer.go @@ -88,6 +88,7 @@ type RendererOptions struct { Title string // Document title (used if CompletePage is set) CSS string // Optional CSS file URL (used if CompletePage is set) Icon string // Optional icon file URL (used if CompletePage is set) + Head []byte // Optional head data injected in the section (used if CompletePage is set) Flags Flags // Flags allow customizing this renderer's behavior @@ -1025,6 +1026,9 @@ func (r *Renderer) writeDocumentHeader(w io.Writer) { io.WriteString(w, ending) io.WriteString(w, ">\n") } + if r.opts.Head != nil { + w.Write(r.opts.Head) + } io.WriteString(w, "\n") io.WriteString(w, "\n\n") }