Skip to content

Commit

Permalink
Merge pull request #95 from odinuge/readmeTxt
Browse files Browse the repository at this point in the history
Fix rendering of non-markdown readme files
  • Loading branch information
metalmatze authored Nov 6, 2016
2 parents 6e4252d + 530f6c1 commit 92c48da
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions routers/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ func renderDirectory(ctx *context.Context, treeLink string) {
ctx.Data["IsMarkdown"] = true
buf = markdown.Render(buf, treeLink, ctx.Repo.Repository.ComposeMetas())
default:
// FIXME This is the only way to show non-markdown files
// instead of a broken "View Raw" link
ctx.Data["IsMarkdown"] = true
buf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)
}
ctx.Data["FileContent"] = string(buf)
Expand Down Expand Up @@ -156,8 +159,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st

readmeExist := isMarkdown || markdown.IsReadmeFile(blob.Name())
ctx.Data["ReadmeExist"] = readmeExist
if readmeExist {
// TODO: don't need to render if it's a README but not Markdown file.
if readmeExist && isMarkdown {
ctx.Data["FileContent"] = string(markdown.Render(buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
} else {
// Building code view blocks with line number on server side.
Expand Down

0 comments on commit 92c48da

Please sign in to comment.