mirror of
https://github.com/go-gitea/gitea
synced 2025-07-08 11:37:20 +00:00
Vendor update: github.com/yuin/goldmark v1.2.1 (#12377)
Thanks to @yuin fix #12376
This commit is contained in:
37
vendor/github.com/yuin/goldmark/util/util.go
generated
vendored
37
vendor/github.com/yuin/goldmark/util/util.go
generated
vendored
@ -8,6 +8,7 @@ import (
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
@ -27,6 +28,7 @@ func NewCopyOnWriteBuffer(buffer []byte) CopyOnWriteBuffer {
|
||||
}
|
||||
|
||||
// Write writes given bytes to the buffer.
|
||||
// Write allocate new buffer and clears it at the first time.
|
||||
func (b *CopyOnWriteBuffer) Write(value []byte) {
|
||||
if !b.copied {
|
||||
b.buffer = make([]byte, 0, len(b.buffer)+20)
|
||||
@ -35,7 +37,20 @@ func (b *CopyOnWriteBuffer) Write(value []byte) {
|
||||
b.buffer = append(b.buffer, value...)
|
||||
}
|
||||
|
||||
// Append appends given bytes to the buffer.
|
||||
// Append copy buffer at the first time.
|
||||
func (b *CopyOnWriteBuffer) Append(value []byte) {
|
||||
if !b.copied {
|
||||
tmp := make([]byte, len(b.buffer), len(b.buffer)+20)
|
||||
copy(tmp, b.buffer)
|
||||
b.buffer = tmp
|
||||
b.copied = true
|
||||
}
|
||||
b.buffer = append(b.buffer, 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) {
|
||||
if !b.copied {
|
||||
b.buffer = make([]byte, 0, len(b.buffer)+20)
|
||||
@ -44,6 +59,18 @@ func (b *CopyOnWriteBuffer) WriteByte(c byte) {
|
||||
b.buffer = append(b.buffer, c)
|
||||
}
|
||||
|
||||
// AppendByte appends given bytes to the buffer.
|
||||
// AppendByte copy buffer at the first time.
|
||||
func (b *CopyOnWriteBuffer) AppendByte(c byte) {
|
||||
if !b.copied {
|
||||
tmp := make([]byte, len(b.buffer), len(b.buffer)+20)
|
||||
copy(tmp, b.buffer)
|
||||
b.buffer = tmp
|
||||
b.copied = true
|
||||
}
|
||||
b.buffer = append(b.buffer, c)
|
||||
}
|
||||
|
||||
// Bytes returns bytes of this buffer.
|
||||
func (b *CopyOnWriteBuffer) Bytes() []byte {
|
||||
return b.buffer
|
||||
@ -777,11 +804,21 @@ func IsPunct(c byte) bool {
|
||||
return punctTable[c] == 1
|
||||
}
|
||||
|
||||
// IsPunct returns true if the given rune is a punctuation, otherwise false.
|
||||
func IsPunctRune(r rune) bool {
|
||||
return int32(r) <= 256 && IsPunct(byte(r)) || unicode.IsPunct(r)
|
||||
}
|
||||
|
||||
// IsSpace returns true if the given character is a space, otherwise false.
|
||||
func IsSpace(c byte) bool {
|
||||
return spaceTable[c] == 1
|
||||
}
|
||||
|
||||
// IsSpace returns true if the given rune is a space, otherwise false.
|
||||
func IsSpaceRune(r rune) bool {
|
||||
return int32(r) <= 256 && IsSpace(byte(r)) || unicode.IsSpace(r)
|
||||
}
|
||||
|
||||
// IsNumeric returns true if the given character is a numeric, otherwise false.
|
||||
func IsNumeric(c byte) bool {
|
||||
return c >= '0' && c <= '9'
|
||||
|
Reference in New Issue
Block a user