Improve html entities replacement

No need to replace html entities in the result - we can just do it when we
write a text node - the only thing that actually contains text and thus
entities!
This commit is contained in:
Niklas Fasching 2018-12-13 17:43:31 +01:00
parent a55ed30e3d
commit 0255a129e2

View file

@ -58,13 +58,6 @@ func (w *HTMLWriter) before(d *Document) {}
func (w *HTMLWriter) after(d *Document) {
w.writeFootnotes(d)
w.replaceHTMLEntities(d)
}
func (w *HTMLWriter) replaceHTMLEntities(d *Document) {
s := w.stringBuilder.String()
w.stringBuilder.Reset()
w.stringBuilder.WriteString(htmlEntityReplacer.Replace(s))
}
func (w *HTMLWriter) writeNodes(ns ...Node) {
@ -188,7 +181,7 @@ func (w *HTMLWriter) writeHeadline(h Headline) {
}
func (w *HTMLWriter) writeText(t Text) {
w.WriteString(html.EscapeString(t.Content))
w.WriteString(html.EscapeString(htmlEntityReplacer.Replace(t.Content)))
}
func (w *HTMLWriter) writeEmphasis(e Emphasis) {