diff --git a/extension/table.go b/extension/table.go index f0e994e..580ca9e 100644 --- a/extension/table.go +++ b/extension/table.go @@ -419,7 +419,7 @@ func (r *TableHTMLRenderer) renderTableCell(w util.BufWriter, source []byte, nod cob.AppendByte(';') } style := fmt.Sprintf("text-align:%s", n.Alignment.String()) - cob.Append(util.StringToReadOnlyBytes(style)) + cob.AppendString(style) n.SetAttributeString("style", cob.Bytes()) } } diff --git a/parser/raw_html.go b/parser/raw_html.go index d7ba414..9fd9e22 100644 --- a/parser/raw_html.go +++ b/parser/raw_html.go @@ -2,10 +2,11 @@ package parser import ( "bytes" + "regexp" + "github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/text" "github.com/yuin/goldmark/util" - "regexp" ) type rawHTMLParser struct { @@ -102,7 +103,3 @@ func (s *rawHTMLParser) parseMultiLineRegexp(reg *regexp.Regexp, block text.Read } return nil } - -func (s *rawHTMLParser) CloseBlock(parent ast.Node, pc Context) { - // nothing to do -} diff --git a/util/util.go b/util/util.go index fc1438d..be82394 100644 --- a/util/util.go +++ b/util/util.go @@ -37,6 +37,12 @@ func (b *CopyOnWriteBuffer) Write(value []byte) { b.buffer = append(b.buffer, value...) } +// WriteString writes given string to the buffer. +// WriteString allocate new buffer and clears it at the first time. +func (b *CopyOnWriteBuffer) WriteString(value string) { + b.Write(StringToReadOnlyBytes(value)) +} + // Append appends given bytes to the buffer. // Append copy buffer at the first time. func (b *CopyOnWriteBuffer) Append(value []byte) { @@ -49,6 +55,12 @@ func (b *CopyOnWriteBuffer) Append(value []byte) { b.buffer = append(b.buffer, value...) } +// AppendString appends given string to the buffer. +// AppendString copy buffer at the first time. +func (b *CopyOnWriteBuffer) AppendString(value string) { + b.Append(StringToReadOnlyBytes(value)) +} + // WriteByte writes the given byte to the buffer. // WriteByte allocate new buffer and clears it at the first time. func (b *CopyOnWriteBuffer) WriteByte(c byte) {