From 3e0a27157c8a87d8da166530f290260264185b4e Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Mon, 1 Feb 2016 19:52:47 +0000 Subject: [PATCH] Make highlighted markdown code blocks work on issue pages --- public/js/gogs.js | 3 +++ routers/repo/issue.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/public/js/gogs.js b/public/js/gogs.js index f979df076..6c00d2776 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -18,6 +18,9 @@ function initCommentPreviewTab($form) { var $preview_tab = $form.find('.tab.segment[data-tab="' + $tab_menu.data('preview') + '"]'); $preview_tab.html(data); emojify.run($preview_tab[0]); + $('pre code', $preview_tab[0]).each(function(i, block) { + hljs.highlightBlock(block); + }); } ); }); diff --git a/routers/repo/issue.go b/routers/repo/issue.go index a4efb6802..b031e42ce 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -291,6 +291,8 @@ func NewIssue(ctx *middleware.Context) { return } + ctx.Data["RequireHighlightJS"] = true + ctx.HTML(200, ISSUE_NEW) } @@ -623,6 +625,9 @@ func ViewIssue(ctx *middleware.Context) { ctx.Data["Issue"] = issue ctx.Data["IsIssueOwner"] = ctx.Repo.IsAdmin() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id)) ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login" + + ctx.Data["RequireHighlightJS"] = true + ctx.HTML(200, ISSUE_VIEW) }