From c177db69d5c53f359d647a92aed961913fa42e0d Mon Sep 17 00:00:00 2001 From: boojack Date: Tue, 20 Dec 2022 09:44:41 +0800 Subject: [PATCH] chore: update tag regexp (#785) --- server/tag.go | 2 +- web/src/labs/marked/parser/Tag.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/tag.go b/server/tag.go index 5801e3631..3cd7e17cd 100644 --- a/server/tag.go +++ b/server/tag.go @@ -12,7 +12,7 @@ import ( "github.com/labstack/echo/v4" ) -var tagRegexpList = []*regexp.Regexp{regexp.MustCompile(`^#([^\s#]+?) `), regexp.MustCompile(`[^\S]#([^\s#]+?) `), regexp.MustCompile(` #([^\s#]+?) `)} +var tagRegexpList = []*regexp.Regexp{regexp.MustCompile(`^#([^\s#]+?) `), regexp.MustCompile(`^#([^\s#]+?)\s`), regexp.MustCompile(`[^\S]#([^\s#]+?)$`), regexp.MustCompile(`[^\S]#([^\s#]+?) `), regexp.MustCompile(` #([^\s#]+?) `)} func (s *Server) registerTagRoutes(g *echo.Group) { g.GET("/tag", func(c echo.Context) error { diff --git a/web/src/labs/marked/parser/Tag.ts b/web/src/labs/marked/parser/Tag.ts index 93ce49c63..8b2cc2866 100644 --- a/web/src/labs/marked/parser/Tag.ts +++ b/web/src/labs/marked/parser/Tag.ts @@ -1,6 +1,6 @@ import { escape } from "lodash-es"; -export const TAG_REG = /#([^\s#]+?) /; +export const TAG_REG = /#([^\s#]+)/; const renderer = (rawStr: string): string => { const matchResult = rawStr.match(TAG_REG);