From ef630c07569f3aa3568c0ba67e86bbfb6eb3e54b Mon Sep 17 00:00:00 2001 From: Camden Cheek Date: Tue, 9 Apr 2024 17:53:39 -0600 Subject: [PATCH] trim newlines for display --- web/server.go | 3 +++ web/templates.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/server.go b/web/server.go index a8b237215..6476ca69b 100644 --- a/web/server.go +++ b/web/server.go @@ -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 diff --git a/web/templates.go b/web/templates.go index ee9f7cbdc..2c5f4026a 100644 --- a/web/templates.go +++ b/web/templates.go @@ -245,7 +245,7 @@ document.onkeydown=function(e){ {{if gt .LineNum 0}} -
{{if .URL}}{{end}}{{.LineNum}}{{if .URL}}{{end}}: {{range .Fragments}}{{LimitPre 100 .Pre}}{{.Match}}{{LimitPost 100 .Post}}{{end}} {{if .ScoreDebug}}({{.ScoreDebug}}){{end}}
+
{{if .URL}}{{end}}{{.LineNum}}{{if .URL}}{{end}}: {{range .Fragments}}{{LimitPre 100 .Pre}}{{.Match}}{{LimitPost 100 (TrimTrailingNewline .Post)}}{{end}} {{if .ScoreDebug}}({{.ScoreDebug}}){{end}}
{{end}}