Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
e1c8101d
Commit
e1c8101d
authored
Feb 02, 2026
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: preserve tag case when extracting markdown tags
Fixes #5566
parent
34c341c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
16 deletions
+15
-16
markdown.go
plugin/markdown/markdown.go
+10
-11
markdown_test.go
plugin/markdown/markdown_test.go
+5
-5
No files found.
plugin/markdown/markdown.go
View file @
e1c8101d
...
@@ -134,8 +134,8 @@ func (s *service) ExtractTags(content []byte) ([]string, error) {
...
@@ -134,8 +134,8 @@ func (s *service) ExtractTags(content []byte) ([]string, error) {
return
nil
,
err
return
nil
,
err
}
}
// Deduplicate
and normalize tags
// Deduplicate
tags while preserving original case
return
unique
Lowerc
ase
(
tags
),
nil
return
unique
PreserveC
ase
(
tags
),
nil
}
}
// ExtractProperties computes boolean properties about the content.
// ExtractProperties computes boolean properties about the content.
...
@@ -334,8 +334,8 @@ func (s *service) ExtractAll(content []byte) (*ExtractedData, error) {
...
@@ -334,8 +334,8 @@ func (s *service) ExtractAll(content []byte) (*ExtractedData, error) {
return
nil
,
err
return
nil
,
err
}
}
// Deduplicate
and normalize tags
// Deduplicate
tags while preserving original case
data
.
Tags
=
unique
Lowerc
ase
(
data
.
Tags
)
data
.
Tags
=
unique
PreserveC
ase
(
data
.
Tags
)
return
data
,
nil
return
data
,
nil
}
}
...
@@ -372,16 +372,15 @@ func (s *service) RenameTag(content []byte, oldTag, newTag string) (string, erro
...
@@ -372,16 +372,15 @@ func (s *service) RenameTag(content []byte, oldTag, newTag string) (string, erro
return
mdRenderer
.
Render
(
root
,
content
),
nil
return
mdRenderer
.
Render
(
root
,
content
),
nil
}
}
// unique
Lowercase returns unique lowercase strings from input
.
// unique
PreserveCase returns unique strings from input while preserving case
.
func
unique
Lowerc
ase
(
strs
[]
string
)
[]
string
{
func
unique
PreserveC
ase
(
strs
[]
string
)
[]
string
{
seen
:=
make
(
map
[
string
]
bool
)
seen
:=
make
(
map
[
string
]
struct
{}
)
var
result
[]
string
var
result
[]
string
for
_
,
s
:=
range
strs
{
for
_
,
s
:=
range
strs
{
lower
:=
strings
.
ToLower
(
s
)
if
_
,
exists
:=
seen
[
s
];
!
exists
{
if
!
seen
[
lower
]
{
seen
[
s
]
=
struct
{}{}
seen
[
lower
]
=
true
result
=
append
(
result
,
s
)
result
=
append
(
result
,
lower
)
}
}
}
}
...
...
plugin/markdown/markdown_test.go
View file @
e1c8101d
...
@@ -223,7 +223,7 @@ func TestExtractTags(t *testing.T) {
...
@@ -223,7 +223,7 @@ func TestExtractTags(t *testing.T) {
name
:
"duplicate tags"
,
name
:
"duplicate tags"
,
content
:
"#work is important. #Work #WORK"
,
content
:
"#work is important. #Work #WORK"
,
withExt
:
true
,
withExt
:
true
,
expected
:
[]
string
{
"work"
},
// Deduplicated and lowercased
expected
:
[]
string
{
"work"
,
"Work"
,
"WORK"
},
},
},
{
{
name
:
"tags with hyphens and underscores"
,
name
:
"tags with hyphens and underscores"
,
...
@@ -315,7 +315,7 @@ func TestExtractTags(t *testing.T) {
...
@@ -315,7 +315,7 @@ func TestExtractTags(t *testing.T) {
}
}
}
}
func
TestUnique
Lowerc
ase
(
t
*
testing
.
T
)
{
func
TestUnique
PreserveC
ase
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
name
string
name
string
input
[]
string
input
[]
string
...
@@ -334,18 +334,18 @@ func TestUniqueLowercase(t *testing.T) {
...
@@ -334,18 +334,18 @@ func TestUniqueLowercase(t *testing.T) {
{
{
name
:
"duplicates"
,
name
:
"duplicates"
,
input
:
[]
string
{
"tag"
,
"TAG"
,
"Tag"
},
input
:
[]
string
{
"tag"
,
"TAG"
,
"Tag"
},
expected
:
[]
string
{
"tag"
},
expected
:
[]
string
{
"tag"
,
"TAG"
,
"Tag"
},
},
},
{
{
name
:
"mixed"
,
name
:
"mixed"
,
input
:
[]
string
{
"Work"
,
"work"
,
"Important"
,
"work"
},
input
:
[]
string
{
"Work"
,
"work"
,
"Important"
,
"work"
},
expected
:
[]
string
{
"
work"
,
"i
mportant"
},
expected
:
[]
string
{
"
Work"
,
"work"
,
"I
mportant"
},
},
},
}
}
for
_
,
tt
:=
range
tests
{
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
result
:=
unique
Lowerc
ase
(
tt
.
input
)
result
:=
unique
PreserveC
ase
(
tt
.
input
)
assert
.
ElementsMatch
(
t
,
tt
.
expected
,
result
)
assert
.
ElementsMatch
(
t
,
tt
.
expected
,
result
)
})
})
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment