Skip to content

Apply external markup rendering to non-text files #4996

Closed
@causal-agent

Description

@causal-agent
  • Gitea version (or commit ref): 1.4.3
  • Git version: 2.18.0
  • Operating system: FreeBSD 11.2-RELEASE
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

Currently, files are only checked against external markup extensions when the file is a text file:

gitea/routers/repo/view.go

Lines 201 to 214 in fc0001c

case isTextFile:
if blob.Size() >= setting.UI.MaxDisplayFileSize {
ctx.Data["IsFileTooLarge"] = true
break
}
d, _ := ioutil.ReadAll(dataRc)
buf = templates.ToUTF8WithFallback(append(buf, d...))
readmeExist := markup.IsReadmeFile(blob.Name())
ctx.Data["ReadmeExist"] = readmeExist
if markup.Type(blob.Name()) != "" {
ctx.Data["IsMarkup"] = true
ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))

I would like to be able to use external markup renderers to render previews of some binary formats, similar to how PDFs can be displayed inline. Instead, I always get the "view raw" page for binary files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/enhancementAn improvement of existing functionalitytype/proposalThe new feature has not been accepted yet but needs to be discussed first.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions