Closed Rooyca closed 1 day ago
#tag#
is not a valid tag. So that wont work. It's only colon tags that are formatted like this, :tag:
.
But yes, #2024
also does not show up, while #2024a
does.
Placing in frontmatter also doesn't work:
---
tags: 2024
---
I'll have a look and see if this is a bug or perhaps by design.
tag# is not a valid tag
Is just a #multi-word tag#
?
I'll have a look and see if this is a bug or perhaps by design.
Thanks.
True yes, #this is a multi-word tag#
.
How confident are you in doing the initial investigation yourself btw? (just saw you ticked the box 😜)
I was doing that, I remember I came to a part where I didn't understand what was going on with the code and give up. I could try it again tho.
Have another crack and just write here with where you get up to :) If you like and find it fun / a learning exercise. If not, then not a stress!
I'll do it :smile:
Hey @tjex, I believe I found something at internal/adapter/markdown/extensions/tag.go
.
It looks like the tags cannot be numbers. But only when using #
.
func isValidHashTag(tag string) bool {
for _, char := range tag {
if !unicode.IsNumber(char) {
return true
}
}
return false
}
Is this a bug or a feature? Looks like is intended but I don't understand why.
Great find 👌 I'll have a look and see if I come up with anything.
I can't see any reason in the code why a hash tag cannot be a number. I also can't find any markdown spec or standards pointing towards a number not being a valid hash tag.
@mickael-menu , can you remember the reasoning behind this choice? isValidHashTag
is only used once on line 162 along with a check for 0 character length.
tag = strings.TrimSpace(tag)
if len(tag) == 0 || !isValidHashTag(tag) {
return nil
}
@Rooyca While I can't see any specific reason why hashtags can't be numbers. It has been designed this way, and changing it could (naturally) have unintended consequences. Perhaps something odd goes on with sql parsing, or some other process.
What makes me particularly hesitant is that there have been specific tests for this made by Mickael:
He most definitely knows what he's doing, so without him reporting back by now to reconsider an initial decision, I'd prefer to request that you add a letter in there somewhere to make it a valid tag, e.g, #Y2024
, rather than me going about changing code and a respective test.
I couldn't think of a good use case for a pure number tag, and treating it as tags can trigger a lot of false positive.
As @tjex mentioned, I'd recommend prefixing the number with a letter to qualify it.
Check if applicable
Describe the bug
I have a file with this tag #2024 and when I use
zk tag
the tag is not displayed, if a change it for something like #2024/06 the tag appears.If I use :2024: it works. If I use #2024# it doesn't.
How to reproduce?
zk tag
zk configuration
Environment