@@ -93,16 +93,12 @@ func renderDirectory(ctx *context.Context, treeLink string) {
9393 if isTextFile {
9494 d , _ := ioutil .ReadAll (dataRc )
9595 buf = append (buf , d ... )
96- newbuf := markup . Render ( readmeFile . Name (), buf , treeLink , ctx . Repo . Repository . ComposeMetas ())
97- if newbuf != nil {
98- ctx .Data ["IsMarkdown " ] = 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 ()))
9999 } else {
100- // FIXME This is the only way to show non-markdown files
101- // instead of a broken "View Raw" link
102- ctx .Data ["IsMarkdown" ] = true
103- newbuf = bytes .Replace (buf , []byte ("\n " ), []byte (`<br>` ), - 1 )
100+ ctx .Data ["FileContent" ] = string (bytes .Replace (buf , []byte ("\n " ), []byte (`<br>` ), - 1 ))
104101 }
105- ctx .Data ["FileContent" ] = string (newbuf )
106102 }
107103 }
108104
@@ -188,15 +184,14 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
188184 d , _ := ioutil .ReadAll (dataRc )
189185 buf = append (buf , d ... )
190186
191- tp := markup .Type (blob .Name ())
192- isSupportedMarkup := tp != ""
193- // FIXME: currently set IsMarkdown for compatible
194- ctx .Data ["IsMarkdown" ] = isSupportedMarkup
195-
196- readmeExist := isSupportedMarkup || markup .IsReadmeFile (blob .Name ())
187+ readmeExist := markup .IsReadmeFile (blob .Name ())
197188 ctx .Data ["ReadmeExist" ] = readmeExist
198- if readmeExist && isSupportedMarkup {
189+ if markup .Type (blob .Name ()) != "" {
190+ ctx .Data ["IsRenderedHTML" ] = true
199191 ctx .Data ["FileContent" ] = string (markup .Render (blob .Name (), buf , path .Dir (treeLink ), ctx .Repo .Repository .ComposeMetas ()))
192+ } else if readmeExist {
193+ ctx .Data ["IsRenderedHTML" ] = true
194+ ctx .Data ["FileContent" ] = string (bytes .Replace (buf , []byte ("\n " ), []byte (`<br>` ), - 1 ))
200195 } else {
201196 // Building code view blocks with line number on server side.
202197 var fileContent string
0 commit comments