diff options
author | 2023-07-24 10:21:14 +0000 | |
---|---|---|
committer | 2023-07-24 10:21:14 +0000 | |
commit | b05f6c8f56684cca0754dadfe673b9a13db6ab42 (patch) | |
tree | bc4d52ae6e83e3ed06ff80268bb08be7b7184a78 /vendor/github.com/yuin/goldmark/text | |
parent | [chore]: Bump codeberg.org/gruf/go-cache/v3 from 3.4.1 to 3.4.3 (#2022) (diff) | |
download | gotosocial-b05f6c8f56684cca0754dadfe673b9a13db6ab42.tar.xz |
[chore]: Bump github.com/yuin/goldmark from 1.5.4 to 1.5.5 (#2023)
Diffstat (limited to 'vendor/github.com/yuin/goldmark/text')
-rw-r--r-- | vendor/github.com/yuin/goldmark/text/reader.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/vendor/github.com/yuin/goldmark/text/reader.go b/vendor/github.com/yuin/goldmark/text/reader.go index 319f1c8b8..d43690a19 100644 --- a/vendor/github.com/yuin/goldmark/text/reader.go +++ b/vendor/github.com/yuin/goldmark/text/reader.go @@ -1,6 +1,7 @@ package text import ( + "bytes" "io" "regexp" "unicode/utf8" @@ -537,24 +538,30 @@ func matchReader(r Reader, reg *regexp.Regexp) bool { } func findSubMatchReader(r Reader, reg *regexp.Regexp) [][]byte { - oldline, oldseg := r.Position() + oldLine, oldSeg := r.Position() match := reg.FindReaderSubmatchIndex(r) - r.SetPosition(oldline, oldseg) + r.SetPosition(oldLine, oldSeg) if match == nil { return nil } - runes := make([]rune, 0, match[1]-match[0]) + var bb bytes.Buffer + bb.Grow(match[1] - match[0]) for i := 0; i < match[1]; { r, size, _ := readRuneReader(r) i += size - runes = append(runes, r) + bb.WriteRune(r) } - result := [][]byte{} + bs := bb.Bytes() + var result [][]byte for i := 0; i < len(match); i += 2 { - result = append(result, []byte(string(runes[match[i]:match[i+1]]))) + if match[i] < 0 { + result = append(result, []byte{}) + continue + } + result = append(result, bs[match[i]:match[i+1]]) } - r.SetPosition(oldline, oldseg) + r.SetPosition(oldLine, oldSeg) r.Advance(match[1] - match[0]) return result } |