From bc9927f4e8d6ff22b77f981e1a994aff96f5f9d4 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 7 Jun 2026 13:19:59 +0800 Subject: [PATCH] fine tune --- modules/markup/markdown/transform_codespan.go | 11 ++++++----- routers/api/v1/admin/user.go | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/markup/markdown/transform_codespan.go b/modules/markup/markdown/transform_codespan.go index d4d2803a614..989d139d340 100644 --- a/modules/markup/markdown/transform_codespan.go +++ b/modules/markup/markdown/transform_codespan.go @@ -68,10 +68,11 @@ func cssColorHandler(value string) bool { } func (g *ASTTransformer) transformCodeSpan(_ *markup.RenderContext, v *ast.CodeSpan, reader text.Reader) { - if v.FirstChild() != nil && v.FirstChild() == v.LastChild() { - colorContent := v.FirstChild().Text(reader.Source()) - if cssColorHandler(string(colorContent)) { - v.AppendChild(v, NewColorPreview(colorContent)) - } + if v.FirstChild() == nil || v.FirstChild() != v.LastChild() { + return + } + colorContent := v.FirstChild().Text(reader.Source()) + if cssColorHandler(string(colorContent)) { + v.AppendChild(v, NewColorPreview(colorContent)) } } diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index b027a6450df..9441fe0c18e 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -287,7 +287,7 @@ func DeleteUser(ctx *context.APIContext) { // "$ref": "#/responses/validationError" if ctx.ContextUser.IsOrganization() { - ctx.APIError(http.StatusUnprocessableEntity, "target is an organization but not an user") + ctx.APIError(http.StatusUnprocessableEntity, "target is an organization but not user") return } @@ -547,7 +547,7 @@ func RenameUser(ctx *context.APIContext) { // "$ref": "#/responses/validationError" if ctx.ContextUser.IsOrganization() { - ctx.APIError(http.StatusUnprocessableEntity, "target is an organization but not an user") + ctx.APIError(http.StatusUnprocessableEntity, "target is an organization but not user") return }