From 0255a129e29883d290b52e951b5840ff4b4c4225 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Thu, 13 Dec 2018 17:43:31 +0100 Subject: [PATCH] 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! --- org/html.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/org/html.go b/org/html.go index e58e39e..575cde3 100644 --- a/org/html.go +++ b/org/html.go @@ -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) {