diff options
author | Lauris BH <lauris@nix.lv> | 2022-06-09 00:46:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 00:46:39 +0300 |
commit | f92b7a633179332053f9fe78190a045637e5ee99 (patch) | |
tree | 708f7f073cca813e111a7b3baabde6110fb4f6f8 /routers/web/repo/view.go | |
parent | 8fee7c46c16cbc1b46477cf600160f9668b9f5d0 (diff) | |
download | gitea-f92b7a633179332053f9fe78190a045637e5ee99.tar.gz gitea-f92b7a633179332053f9fe78190a045637e5ee99.zip |
Add support for rendering terminal output with colors (#19497)
Diffstat (limited to 'routers/web/repo/view.go')
-rw-r--r-- | routers/web/repo/view.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 2c9e16de5b..48565cb62b 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -509,6 +509,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["ReadmeExist"] = readmeExist markupType := markup.Type(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 + if markupType == "" { + detected = true + markupType = markup.DetectRendererType(blob.Name(), bytes.NewReader(buf)) + } if markupType != "" { ctx.Data["HasSourceRenderedToggle"] = true } @@ -517,8 +524,12 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st ctx.Data["IsMarkup"] = true ctx.Data["MarkupType"] = markupType var result strings.Builder + if !detected { + markupType = "" + } err := markup.Render(&markup.RenderContext{ Ctx: ctx, + Type: markupType, Filename: blob.Name(), URLPrefix: path.Dir(treeLink), Metas: ctx.Repo.Repository.ComposeDocumentMetas(), |