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.
This commit is contained in:
parent
6dd8e90bb8
commit
cec002db22
1 changed files with 3 additions and 0 deletions
|
@ -47,7 +47,10 @@ var listItemStatuses = map[string]string{
|
|||
var cleanHeadlineTitleForHTMLAnchorRegexp = regexp.MustCompile(`</?a[^>]*>`) // 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<pre>\n%s\n</pre>\n</div>", `<div class="highlight">`, html.EscapeString(source))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue