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:
parent
a55ed30e3d
commit
0255a129e2
1 changed files with 1 additions and 8 deletions
|
@ -58,13 +58,6 @@ func (w *HTMLWriter) before(d *Document) {}
|
||||||
|
|
||||||
func (w *HTMLWriter) after(d *Document) {
|
func (w *HTMLWriter) after(d *Document) {
|
||||||
w.writeFootnotes(d)
|
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) {
|
func (w *HTMLWriter) writeNodes(ns ...Node) {
|
||||||
|
@ -188,7 +181,7 @@ func (w *HTMLWriter) writeHeadline(h Headline) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *HTMLWriter) writeText(t Text) {
|
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) {
|
func (w *HTMLWriter) writeEmphasis(e Emphasis) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue