mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Refactoring
This commit is contained in:
parent
d102aef53c
commit
7b90f04af4
3 changed files with 15 additions and 6 deletions
|
|
@ -419,7 +419,7 @@ func (r *TableHTMLRenderer) renderTableCell(w util.BufWriter, source []byte, nod
|
||||||
cob.AppendByte(';')
|
cob.AppendByte(';')
|
||||||
}
|
}
|
||||||
style := fmt.Sprintf("text-align:%s", n.Alignment.String())
|
style := fmt.Sprintf("text-align:%s", n.Alignment.String())
|
||||||
cob.Append(util.StringToReadOnlyBytes(style))
|
cob.AppendString(style)
|
||||||
n.SetAttributeString("style", cob.Bytes())
|
n.SetAttributeString("style", cob.Bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ package parser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"github.com/yuin/goldmark/ast"
|
"github.com/yuin/goldmark/ast"
|
||||||
"github.com/yuin/goldmark/text"
|
"github.com/yuin/goldmark/text"
|
||||||
"github.com/yuin/goldmark/util"
|
"github.com/yuin/goldmark/util"
|
||||||
"regexp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type rawHTMLParser struct {
|
type rawHTMLParser struct {
|
||||||
|
|
@ -102,7 +103,3 @@ func (s *rawHTMLParser) parseMultiLineRegexp(reg *regexp.Regexp, block text.Read
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *rawHTMLParser) CloseBlock(parent ast.Node, pc Context) {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
|
|
|
||||||
12
util/util.go
12
util/util.go
|
|
@ -37,6 +37,12 @@ func (b *CopyOnWriteBuffer) Write(value []byte) {
|
||||||
b.buffer = append(b.buffer, value...)
|
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 appends given bytes to the buffer.
|
||||||
// Append copy buffer at the first time.
|
// Append copy buffer at the first time.
|
||||||
func (b *CopyOnWriteBuffer) Append(value []byte) {
|
func (b *CopyOnWriteBuffer) Append(value []byte) {
|
||||||
|
|
@ -49,6 +55,12 @@ func (b *CopyOnWriteBuffer) Append(value []byte) {
|
||||||
b.buffer = append(b.buffer, value...)
|
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 writes the given byte to the buffer.
|
||||||
// WriteByte allocate new buffer and clears it at the first time.
|
// WriteByte allocate new buffer and clears it at the first time.
|
||||||
func (b *CopyOnWriteBuffer) WriteByte(c byte) {
|
func (b *CopyOnWriteBuffer) WriteByte(c byte) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue