@@ -94,16 +94,11 @@ func renderDirectory(ctx *context.Context, treeLink string) {
94
94
d , _ := ioutil .ReadAll (dataRc )
95
95
buf = append (buf , d ... )
96
96
ctx .Data ["IsRenderedHTML" ] = true
97
- newbuf := markup .Render (readmeFile .Name (), buf , treeLink , ctx .Repo .Repository .ComposeMetas ())
98
- if newbuf != nil {
99
- ctx .Data ["IsMarkup" ] = true
97
+ if markup .Type (readmeFile .Name ()) != "" {
98
+ ctx .Data ["FileContent" ] = string (markup .Render (readmeFile .Name (), buf , treeLink , ctx .Repo .Repository .ComposeMetas ()))
100
99
} else {
101
- // FIXME This is the only way to show non-markdown files
102
- // instead of a broken "View Raw" link
103
- ctx .Data ["IsMarkup" ] = false
104
- newbuf = bytes .Replace (buf , []byte ("\n " ), []byte (`<br>` ), - 1 )
100
+ ctx .Data ["FileContent" ] = string (bytes .Replace (buf , []byte ("\n " ), []byte (`<br>` ), - 1 ))
105
101
}
106
- ctx .Data ["FileContent" ] = string (newbuf )
107
102
}
108
103
}
109
104
@@ -196,15 +191,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
196
191
d , _ := ioutil .ReadAll (dataRc )
197
192
buf = append (buf , d ... )
198
193
199
- tp := markup .Type (blob .Name ())
200
- isSupportedMarkup := tp != ""
201
- ctx .Data ["IsMarkup" ] = isSupportedMarkup
202
194
readmeExist := markup .IsReadmeFile (blob .Name ())
203
195
ctx .Data ["ReadmeExist" ] = readmeExist
204
- ctx . Data [ "IsRenderedHTML" ] = true
205
- if isSupportedMarkup {
196
+ if markup . Type ( blob . Name ()) != "" {
197
+ ctx . Data [ "IsRenderedHTML" ] = true
206
198
ctx .Data ["FileContent" ] = string (markup .Render (blob .Name (), buf , path .Dir (treeLink ), ctx .Repo .Repository .ComposeMetas ()))
207
199
} else if readmeExist {
200
+ ctx .Data ["IsRenderedHTML" ] = true
208
201
ctx .Data ["FileContent" ] = string (bytes .Replace (buf , []byte ("\n " ), []byte (`<br>` ), - 1 ))
209
202
} else {
210
203
// Building code view blocks with line number on server side.
0 commit comments