From 97235182ac5e768200740f8050b75e07bb97a43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytautas=20=C5=A0altenis?= Date: Mon, 9 Nov 2015 21:14:32 +0200 Subject: [PATCH] Enable writing plain text straight to output It's only used in a single place and should probably be refactored away, but this workaround is OK for now. --- html.go | 4 ++++ inline.go | 2 +- latex.go | 4 ++++ markdown.go | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/html.go b/html.go index e43495d..06685e4 100644 --- a/html.go +++ b/html.go @@ -187,6 +187,10 @@ func (r *Html) CopyWrites(processor func()) []byte { return output.Bytes() } +func (r *Html) Write(b []byte) (int, error) { + return r.w.Write(b) +} + func (r *Html) GetResult() []byte { return r.w.output.Bytes() } diff --git a/inline.go b/inline.go index 0a169a8..7779ce7 100644 --- a/inline.go +++ b/inline.go @@ -748,7 +748,7 @@ func autoLink(p *parser, data []byte, offset int) int { anchorStr := anchorRe.Find(data[anchorStart:]) if anchorStr != nil { - out.Write(anchorStr[offsetFromAnchor:]) // XXX: write in parser? + p.r.Write(anchorStr[offsetFromAnchor:]) // XXX: write in parser? return len(anchorStr) - offsetFromAnchor } diff --git a/latex.go b/latex.go index 5f43654..65a352e 100644 --- a/latex.go +++ b/latex.go @@ -60,6 +60,10 @@ func (r *Latex) CopyWrites(processor func()) []byte { return output.Bytes() } +func (r *Latex) Write(b []byte) (int, error) { + return r.w.Write(b) +} + func (r *Latex) GetResult() []byte { return r.w.output.Bytes() } diff --git a/markdown.go b/markdown.go index 39a8347..28782a9 100644 --- a/markdown.go +++ b/markdown.go @@ -204,6 +204,7 @@ type Renderer interface { GetFlags() HtmlFlags CaptureWrites(processor func()) []byte CopyWrites(processor func()) []byte + Write(b []byte) (int, error) GetResult() []byte }