Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: tag regexp (#253)

boojack222c7925394e
diff --git a/server/tag.go b/server/tag.go
index d78242267..48b026793 100644
--- a/server/tag.go
+++ b/server/tag.go
@@ -12,7 +12,7 @@ import (
"github.com/labstack/echo/v4"
)
-var tagRegexp = regexp.MustCompile(`#([^\s#]+?) `)
+var tagRegexp = regexp.MustCompile(`[^\s]?#([^\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 f4fbc9331..a117d0538 100644
--- a/web/src/labs/marked/parser/Tag.ts
+++ b/web/src/labs/marked/parser/Tag.ts
@@ -1,4 +1,4 @@
-export const TAG_REG = /#([^\s#]+?) /;
+export const TAG_REG = /[^\s]?#([^\s#]+?) /;
const match = (rawStr: string): number => {
const matchResult = rawStr.match(TAG_REG);
diff --git a/web/src/labs/marked/parser/index.ts b/web/src/labs/marked/parser/index.ts
index cff22365d..639eeb598 100644
--- a/web/src/labs/marked/parser/index.ts
+++ b/web/src/labs/marked/parser/index.ts
@@ -27,5 +27,5 @@ export { EMPHASIS_REG } from "./Emphasis";
// The order determines the order of execution.
export const blockElementParserList = [CodeBlock, TodoList, DoneList, OrderedList, UnorderedList, Paragraph];
-export const inlineElementParserList = [Image, Mark, Link, Bold, Emphasis, Tag, PlainLink];
+export const inlineElementParserList = [Image, Mark, Link, Bold, Emphasis, PlainLink, Tag];
export const parserList = [...blockElementParserList, ...inlineElementParserList];