Browse Source

fix readme view bug (#2566)

Lunny Xiao 2 years ago
parent
commit
1be2b4a262
1 changed files with 3 additions and 1 deletions
  1. 3 1
      routers/repo/view.go

+ 3 - 1
routers/repo/view.go

@@ -200,8 +200,10 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
200 200
 		ctx.Data["IsMarkup"] = isSupportedMarkup
201 201
 		readmeExist := markup.IsReadmeFile(blob.Name())
202 202
 		ctx.Data["ReadmeExist"] = readmeExist
203
-		if readmeExist && isSupportedMarkup {
203
+		if isSupportedMarkup {
204 204
 			ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
205
+		} else if readmeExist {
206
+			ctx.Data["FileContent"] = string(bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1))
205 207
 		} else {
206 208
 			// Building code view blocks with line number on server side.
207 209
 			var fileContent string