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