summaryrefslogtreecommitdiff
path: root/vendor/github.com/yuin/goldmark/text/segment.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-10-21 11:37:00 +0200
committerLibravatar GitHub <noreply@github.com>2024-10-21 11:37:00 +0200
commitea1bf5f8a37992aa547573a42332235dc7142399 (patch)
tree9f89eabc416ec6339f02d4092182e055a8227f7a /vendor/github.com/yuin/goldmark/text/segment.go
parent[bugfix] Fix filter title unique constraint (#3458) (diff)
downloadgotosocial-ea1bf5f8a37992aa547573a42332235dc7142399.tar.xz
[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] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/yuin/goldmark/text/segment.go')
-rw-r--r--vendor/github.com/yuin/goldmark/text/segment.go26
1 files changed, 23 insertions, 3 deletions
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
+}