Skip to content

Commit

Permalink
Remove final newline from rendered code
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed May 20, 2022
1 parent fd7d83a commit 96238e9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 9 deletions.
7 changes: 0 additions & 7 deletions modules/highlight/highlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,6 @@ func File(numLines int, fileName, language string, code []byte) []string {
}

htmlw.Flush()
finalNewLine := false
if len(code) > 0 {
finalNewLine = code[len(code)-1] == '\n'
}

m := make([]string, 0, numLines)
for _, v := range strings.SplitN(htmlbuf.String(), "\n", numLines) {
Expand All @@ -208,9 +204,6 @@ func File(numLines int, fileName, language string, code []byte) []string {
content = strings.TrimPrefix(content, `</span>`)
m = append(m, content)
}
if finalNewLine {
m = append(m, "<span class=\"w\">\n</span>")
}

return m
}
Expand Down
2 changes: 0 additions & 2 deletions modules/highlight/highlight_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ steps:
`</span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">go build -v</span>`,
`</span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">go test -v -race -coverprofile=coverage.txt -covermode=atomic</span><span class="w">
</span></span></span>`,
`<span class="w">
</span>`,
},
},
{
Expand Down

0 comments on commit 96238e9

Please sign in to comment.