mirror of
https://github.com/russross/blackfriday.git
synced 2024-03-22 13:40:34 +08:00
allow writing of user-specified <meta.../> tags to document header
This commit is contained in:
parent
f3ccc8fc06
commit
269dc6e00d
17
html.go
17
html.go
|
@ -82,6 +82,13 @@ type Html struct {
|
||||||
title string // document title
|
title string // document title
|
||||||
css string // optional css file url (used with HTML_COMPLETE_PAGE)
|
css string // optional css file url (used with HTML_COMPLETE_PAGE)
|
||||||
|
|
||||||
|
// The optional 'meta' map holds additional meta tags to
|
||||||
|
// place into the final document's header.
|
||||||
|
// Format:
|
||||||
|
// key: name="author"
|
||||||
|
// val: foo barrington
|
||||||
|
meta map[string]string
|
||||||
|
|
||||||
parameters HtmlRendererParameters
|
parameters HtmlRendererParameters
|
||||||
|
|
||||||
// table of contents data
|
// table of contents data
|
||||||
|
@ -131,6 +138,8 @@ func HtmlRendererWithParameters(flags int, title string,
|
||||||
css: css,
|
css: css,
|
||||||
parameters: renderParameters,
|
parameters: renderParameters,
|
||||||
|
|
||||||
|
meta: make(map[string]string),
|
||||||
|
|
||||||
headerCount: 0,
|
headerCount: 0,
|
||||||
currentLevel: 0,
|
currentLevel: 0,
|
||||||
toc: new(bytes.Buffer),
|
toc: new(bytes.Buffer),
|
||||||
|
@ -685,6 +694,14 @@ func (options *Html) DocumentHeader(out *bytes.Buffer) {
|
||||||
out.WriteString(" <meta charset=\"utf-8\"")
|
out.WriteString(" <meta charset=\"utf-8\"")
|
||||||
out.WriteString(ending)
|
out.WriteString(ending)
|
||||||
out.WriteString(">\n")
|
out.WriteString(">\n")
|
||||||
|
// plug the user-specified <meta.../> tags
|
||||||
|
if options.meta != nil {
|
||||||
|
for k, v := range options.meta {
|
||||||
|
out.WriteString(" <meta " + k + " content=\"" + v + "\"")
|
||||||
|
out.WriteString(ending)
|
||||||
|
out.WriteString(">\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
if options.css != "" {
|
if options.css != "" {
|
||||||
out.WriteString(" <link rel=\"stylesheet\" type=\"text/css\" href=\"")
|
out.WriteString(" <link rel=\"stylesheet\" type=\"text/css\" href=\"")
|
||||||
attrEscape(out, []byte(options.css))
|
attrEscape(out, []byte(options.css))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user