diff --git a/routers/repo/view.go b/routers/repo/view.go index c4e6a69220..a2e431e435 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -346,6 +346,20 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["IsAudioFile"] = true case base.IsImageFile(buf): ctx.Data["IsImageFile"] = true + default: + if fileSize >= setting.UI.MaxDisplayFileSize { + ctx.Data["IsFileTooLarge"] = true + break + } + + if markupType := markup.Type(blob.Name()); markupType != "" { + d, _ := ioutil.ReadAll(dataRc) + buf = append(buf, d...) + ctx.Data["IsMarkup"] = true + ctx.Data["MarkupType"] = markupType + ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas())) + } + } if ctx.Repo.CanEnableEditor() {