Hashtag linking to categories doesn’t always work

On the Codecademy site, this link does not work: #Codecademy-Community-Lounge:Codecademy-Platform-Problems-and-Suggestions

But this one is fine: #Codecademy-Community-Lounge (of course doesn’t work here)

The non-functional link to the Problems category has the closing span tag stuck in too soon:

Here is another one that doesn’t work: #Codecademy-Community-Lounge:Feature-Course-Requests

It has the same <span> problem, this time just the “s” is cut off.

Looks like there is a 50 character limit on these.

Seems like a easy bug fix…


Credits to @AlbionsRefuge for the initial draft :slight_smile:

3 Likes

@tgxworld this looks like your bug :slight_smile:

1 Like

I found the problem code here:

https://github.com/discourse/discourse/blob/c99775ebdb6324459dcfc65d32bff475bec112b3/app/assets/javascripts/discourse/dialects/category_hashtag_dialect.js

This line:

Discourse.Dialect.inlineRegexp({
  start: '#',
  matcher: /^#([\w-:]{1,50})/i,
  spaceOrTagBoundary: true,

The {1, 50} is causing the issue.

5 Likes

Thanks for finding out the cause of the bug. We need to expand that limit to 101 since category names are limited to 50 chars.

@tgxworld If I may ask, why 101 character limit? :slight_smile: Is it for 50 characters category name+50 characters sub-category name? Then shouldn’t it be 100 char limit?

P.S. I need some help committing code:

I had made this branch name: hashtag_category_linking_fix. I am using GitHub’s Windows client. I do not know why I got the error on the eighth step here (I am following the official guide). I was just trying for fun but that didn’t quite work. Help is appreciated :slight_smile:

That’s because a sub category hashtag will include a :. Ah I see your problem… You have a typo in your branch name hastag_category_linking_fix. Note the missing h

2 Likes

Lol! Now I don’t know how to rename branches, I will just let it remain that way. Trying to push the code again.

Typo in a branch name is fine but in the future, you can rename with

git branch -m <new branch name>

1 Like

After having renamed, now I am getting this:

intl@intl-PC  /f/discourse (hashtag_category_linking_fix)
$ git push mine hashtag_category_linking_fix
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I will probably try these things some other day. Cmd doesn’t like me…

I fixed the problem, made a PR waiting to be merged.

3 Likes

Here is the solution, it’s already been merged:
https://github.com/discourse/discourse/pull/4081/files

Bug can be closed now. @tgxworld @eviltrout

4 Likes