From ea1bf5f8a37992aa547573a42332235dc7142399 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:37:00 +0200 Subject: [chore]: Bump github.com/yuin/goldmark from 1.7.6 to 1.7.8 (#3470) Bumps [github.com/yuin/goldmark](https://github.com/yuin/goldmark) from 1.7.6 to 1.7.8. - [Release notes](https://github.com/yuin/goldmark/releases) - [Commits](https://github.com/yuin/goldmark/compare/v1.7.6...v1.7.8) --- updated-dependencies: - dependency-name: github.com/yuin/goldmark dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- vendor/github.com/yuin/goldmark/text/segment.go | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'vendor/github.com/yuin/goldmark/text') diff --git a/vendor/github.com/yuin/goldmark/text/segment.go b/vendor/github.com/yuin/goldmark/text/segment.go index 83c875bcb..93fbf1994 100644 --- a/vendor/github.com/yuin/goldmark/text/segment.go +++ b/vendor/github.com/yuin/goldmark/text/segment.go @@ -20,8 +20,19 @@ type Segment struct { // Padding is a padding length of the segment. Padding int - // EOB is true if the segment is end of the block. - EOB bool + // ForceNewline is true if the segment should be ended with a newline. + // Some elements(i.e. CodeBlock, FencedCodeBlock) does not trim trailing + // newlines. Spec defines that EOF is treated as a newline, so we need to + // add a newline to the end of the segment if it is not empty. + // + // i.e.: + // + // ```go + // const test = "test" + // + // This code does not close the code block and ends with EOF. In this case, + // we need to add a newline to the end of the last line like `const test = "test"\n`. + ForceNewline bool } // NewSegment return a new Segment. @@ -52,7 +63,7 @@ func (t *Segment) Value(buffer []byte) []byte { result = append(result, bytes.Repeat(space, t.Padding)...) result = append(result, buffer[t.Start:t.Stop]...) } - if t.EOB && len(result) > 0 && result[len(result)-1] != '\n' { + if t.ForceNewline && len(result) > 0 && result[len(result)-1] != '\n' { result = append(result, '\n') } return result @@ -217,3 +228,12 @@ func (s *Segments) Unshift(v Segment) { s.values = append(s.values[0:1], s.values[0:]...) s.values[0] = v } + +// Value returns a string value of the collection. +func (s *Segments) Value(buffer []byte) []byte { + var result []byte + for _, v := range s.values { + result = append(result, v.Value(buffer)...) + } + return result +} -- cgit v1.3