Skip to content

Commit

Permalink
trim newlines for display
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Apr 10, 2024
1 parent 5d3d5a2 commit ef630c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ var Funcmap = template.FuncMap{
}
return fmt.Sprintf("%s...(%d bytes skipped)...", post[:limit], len(post)-limit)
},
"TrimTrailingNewline": func(s string) string {
return strings.TrimSuffix(s, "\n")
},
}

const defaultNumResults = 50
Expand Down
2 changes: 1 addition & 1 deletion web/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ document.onkeydown=function(e){
{{if gt .LineNum 0}}
<tr>
<td style="background-color: rgba(238, 238, 255, 0.6);">
<pre class="inline-pre"><span class="noselect">{{if .URL}}<a href="{{.URL}}">{{end}}<u>{{.LineNum}}</u>{{if .URL}}</a>{{end}}: </span>{{range .Fragments}}{{LimitPre 100 .Pre}}<b>{{.Match}}</b>{{LimitPost 100 .Post}}{{end}} {{if .ScoreDebug}}<i>({{.ScoreDebug}})</i>{{end}}</pre>
<pre class="inline-pre"><span class="noselect">{{if .URL}}<a href="{{.URL}}">{{end}}<u>{{.LineNum}}</u>{{if .URL}}</a>{{end}}: </span>{{range .Fragments}}{{LimitPre 100 .Pre}}<b>{{.Match}}</b>{{LimitPost 100 (TrimTrailingNewline .Post)}}{{end}} {{if .ScoreDebug}}<i>({{.ScoreDebug}})</i>{{end}}</pre>
</td>
</tr>
{{end}}
Expand Down

0 comments on commit ef630c0

Please sign in to comment.