mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
revert: fix: exclude all punctuation chars except underscore in tags (#2033)
Revert "fix: exclude all punctuation chars except underscore in tags (#1974)"
This reverts commit 8c61531671
.
This commit is contained in:
@@ -176,7 +176,7 @@ func convertTagFromStore(tag *store.Tag) *Tag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tagRegexp = regexp.MustCompile(`#((?:[^\s\p{P}]|_)+)`)
|
var tagRegexp = regexp.MustCompile(`#([^\s#,]+)`)
|
||||||
|
|
||||||
func findTagListFromMemoContent(memoContent string) []string {
|
func findTagListFromMemoContent(memoContent string) []string {
|
||||||
tagMapSet := make(map[string]bool)
|
tagMapSet := make(map[string]bool)
|
||||||
|
@@ -2,8 +2,6 @@ package v1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"golang.org/x/exp/slices"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFindTagListFromMemoContent(t *testing.T) {
|
func TestFindTagListFromMemoContent(t *testing.T) {
|
||||||
@@ -37,16 +35,12 @@ func TestFindTagListFromMemoContent(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
memoContent: "#tag1 http://123123.com?123123#tag2 \n#tag3 #tag4 http://123123.com?123123#tag2) ",
|
memoContent: "#tag1 http://123123.com?123123#tag2 \n#tag3 #tag4 http://123123.com?123123#tag2) ",
|
||||||
want: []string{"tag1", "tag2", "tag3", "tag4"},
|
want: []string{"tag1", "tag2", "tag2)", "tag3", "tag4"},
|
||||||
},
|
|
||||||
{
|
|
||||||
memoContent: "#tag1,#tag2! #tag3.. #tag_4",
|
|
||||||
want: []string{"tag1", "tag2", "tag3", "tag_4"},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
result := findTagListFromMemoContent(test.memoContent)
|
result := findTagListFromMemoContent(test.memoContent)
|
||||||
if !slices.Equal(result, test.want) {
|
if len(result) != len(test.want) {
|
||||||
t.Errorf("Find tag list %s: got result %v, want %v.", test.memoContent, result, test.want)
|
t.Errorf("Find tag list %s: got result %v, want %v.", test.memoContent, result, test.want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { matcher } from "../matcher";
|
import { matcher } from "../matcher";
|
||||||
|
|
||||||
export const TAG_REG = /#((?:[^\s\p{P}]|_)+)/u;
|
export const TAG_REG = /#([^\s#,]+)/;
|
||||||
|
|
||||||
const renderer = (rawStr: string) => {
|
const renderer = (rawStr: string) => {
|
||||||
const matchResult = matcher(rawStr, TAG_REG);
|
const matchResult = matcher(rawStr, TAG_REG);
|
||||||
|
Reference in New Issue
Block a user