mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
@@ -47,7 +47,7 @@ func RenderFile(ctx *context.Context) {
|
||||
rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{})
|
||||
ctx.Resp.Header().Add("Content-Security-Policy", "frame-src 'self'; sandbox allow-scripts")
|
||||
|
||||
if markupType := markup.Type(blob.Name()); markupType == "" {
|
||||
if markupType := markup.DetectMarkupTypeByFileName(blob.Name()); markupType == "" {
|
||||
if isTextFile {
|
||||
_, _ = io.Copy(ctx.Resp, rd)
|
||||
} else {
|
||||
|
@@ -307,7 +307,7 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr
|
||||
|
||||
rd := charset.ToUTF8WithFallbackReader(io.MultiReader(bytes.NewReader(buf), dataRc), charset.ConvertOpts{})
|
||||
|
||||
if markupType := markup.Type(readmeFile.Name()); markupType != "" {
|
||||
if markupType := markup.DetectMarkupTypeByFileName(readmeFile.Name()); markupType != "" {
|
||||
ctx.Data["IsMarkup"] = true
|
||||
ctx.Data["MarkupType"] = markupType
|
||||
|
||||
@@ -499,7 +499,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) {
|
||||
readmeExist := util.IsReadmeFileName(blob.Name())
|
||||
ctx.Data["ReadmeExist"] = readmeExist
|
||||
|
||||
markupType := markup.Type(blob.Name())
|
||||
markupType := markup.DetectMarkupTypeByFileName(blob.Name())
|
||||
// If the markup is detected by custom markup renderer it should not be reset later on
|
||||
// to not pass it down to the render context.
|
||||
detected := false
|
||||
@@ -607,7 +607,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) {
|
||||
|
||||
// TODO: this logic duplicates with "isRepresentableAsText=true", it is not the same as "LFSFileGet" in "lfs.go"
|
||||
// It is used by "external renders", markupRender will execute external programs to get rendered content.
|
||||
if markupType := markup.Type(blob.Name()); markupType != "" {
|
||||
if markupType := markup.DetectMarkupTypeByFileName(blob.Name()); markupType != "" {
|
||||
rd := io.MultiReader(bytes.NewReader(buf), dataRc)
|
||||
ctx.Data["IsMarkup"] = true
|
||||
ctx.Data["MarkupType"] = markupType
|
||||
|
@@ -532,7 +532,7 @@ func Wiki(ctx *context.Context) {
|
||||
}
|
||||
|
||||
wikiPath := entry.Name()
|
||||
if markup.Type(wikiPath) != markdown.MarkupName {
|
||||
if markup.DetectMarkupTypeByFileName(wikiPath) != markdown.MarkupName {
|
||||
ext := strings.ToUpper(filepath.Ext(wikiPath))
|
||||
ctx.Data["FormatWarning"] = fmt.Sprintf("%s rendering is not supported at the moment. Rendered as Markdown.", ext)
|
||||
}
|
||||
|
Reference in New Issue
Block a user