From cec002db2261778a3ef69ec64ecc024ef66bdeb8 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Mon, 7 Jan 2019 21:43:50 +0100 Subject: [PATCH] Improve NewHTMLWriter() defaults HTMLWriter uses the document to look up export options and adapt it's behaviour. The writer.document & log are set in the Before() method during normal use via document.Write(). Sometimes the writer is used separately and won't have it's Before method called - in those cases we should use the defaults rather than crashing. --- org/html_writer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/org/html_writer.go b/org/html_writer.go index 60fb58b..4e38274 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -47,7 +47,10 @@ var listItemStatuses = map[string]string{ var cleanHeadlineTitleForHTMLAnchorRegexp = regexp.MustCompile(`]*>`) // nested a tags are not valid HTML func NewHTMLWriter() *HTMLWriter { + defaultConfig := New() return &HTMLWriter{ + document: &Document{Configuration: defaultConfig}, + log: defaultConfig.Log, htmlEscape: true, HighlightCodeBlock: func(source, lang string) string { return fmt.Sprintf("%s\n
\n%s\n
\n", `
`, html.EscapeString(source))