Skip to content

Commit

Permalink
remove unnecessary bytes.Count
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Jul 27, 2022
1 parent 49f62a4 commit c8107f8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions modules/highlight/highlight.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,10 @@ func File(fileName, language string, code []byte) ([]string, error) {

_ = htmlWriter.Flush()

m := make([]string, 0, bytes.Count(code, []byte{'\n'})+1)

// at the moment, Chroma generates stable output `<span class="line"><span class="cl">...\n</span></span>` for each line
htmlStr := htmlBuf.String()
lines := strings.Split(htmlStr, `<span class="line"><span class="cl">`)
m := make([]string, 0, len(lines))
for i := 1; i < len(lines); i++ {
line := lines[i]
line = strings.TrimSuffix(line, "</span></span>")
Expand Down

0 comments on commit c8107f8

Please sign in to comment.