diff options
author | Norwin <noerw@users.noreply.github.com> | 2019-08-15 22:09:50 +0000 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2019-08-16 01:09:50 +0300 |
commit | 867f46f78e5777d7bafe83cda3244c1001ce3e60 (patch) | |
tree | a326328927994bd715fae6a43795624355101412 /routers/repo/view.go | |
parent | 0a86d25e6a1e054ef0ca0a102dd0f2a68dd75f26 (diff) | |
download | gitea-867f46f78e5777d7bafe83cda3244c1001ce3e60.tar.gz gitea-867f46f78e5777d7bafe83cda3244c1001ce3e60.zip |
Detect delimiter in CSV rendering (#7869)
* detect csv delimiter in csv rendering
fixes #7868
* make linter happy
* fix failing testcase & use ints where possible
* expose markup type to template
previously all markup had the .markdown class, which is incorrect,
as it applies markdown CSS & JS logic to CSV rendering
* fix build (missing `make css`)
* ignore quoted csv content for delimiter scoring
also fix html generation
Diffstat (limited to 'routers/repo/view.go')
-rw-r--r-- | routers/repo/view.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go index b534ae0e16..9d24506b47 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -162,8 +162,9 @@ func renderDirectory(ctx *context.Context, treeLink string) { d, _ := ioutil.ReadAll(dataRc) buf = charset.ToUTF8WithFallback(append(buf, d...)) - if markup.Type(readmeFile.Name()) != "" { + if markupType := markup.Type(readmeFile.Name()); markupType != "" { ctx.Data["IsMarkup"] = true + ctx.Data["MarkupType"] = string(markupType) ctx.Data["FileContent"] = string(markup.Render(readmeFile.Name(), buf, treeLink, ctx.Repo.Repository.ComposeMetas())) } else { ctx.Data["IsRenderedHTML"] = true @@ -282,8 +283,9 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st readmeExist := markup.IsReadmeFile(blob.Name()) ctx.Data["ReadmeExist"] = readmeExist - if markup.Type(blob.Name()) != "" { + if markupType := markup.Type(blob.Name()); markupType != "" { ctx.Data["IsMarkup"] = true + ctx.Data["MarkupType"] = markupType ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas())) } else if readmeExist { ctx.Data["IsRenderedHTML"] = true |