html: Fix html writer footnotes (in headlines)

writer.footnotes must be a pointer as we copy the writer in nodesAsString() and
can thus end up modifying the footnotes.list slice without it being reflected in
the original writer (i.e. when the backing array of the slice changes).
This commit is contained in:
Niklas Fasching 2019-08-24 12:11:23 +02:00
parent 97fe8b7850
commit f67a251e27
4 changed files with 69 additions and 2 deletions

View file

@ -19,7 +19,7 @@ type HTMLWriter struct {
HighlightCodeBlock func(source, lang string) string
htmlEscape bool
log *log.Logger
footnotes footnotes
footnotes *footnotes
}
type footnotes struct {
@ -61,7 +61,7 @@ func NewHTMLWriter() *HTMLWriter {
HighlightCodeBlock: func(source, lang string) string {
return fmt.Sprintf("<div class=\"highlight\">\n<pre>\n%s\n</pre>\n</div>", html.EscapeString(source))
},
footnotes: footnotes{
footnotes: &footnotes{
mapping: map[string]int{},
},
}