Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow underscores #6

Closed
philippkuehn opened this issue Apr 22, 2020 · 8 comments
Closed

Allow underscores #6

philippkuehn opened this issue Apr 22, 2020 · 8 comments
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🧒 semver/minor This is backwards-compatible change 🦋 type/enhancement This is great to have

Comments

@philippkuehn
Copy link

Since Twitter also allows underscores in the username, it would be nice if this is would also be supported by this package. @_philippkuehn (my twitter handle) is not recognized.

@philippkuehn philippkuehn added 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Apr 22, 2020
@wooorm
Copy link
Member

wooorm commented Apr 23, 2020

Ah right, makes sense!

var name = /^(?:[a-z0-9]{1,2}|[a-z0-9][a-z0-9-]{1,37}[a-z0-9])([']s)?$/i

the code is currently made specifically for GH, e.g., also to support teams: @foo/bar.
What do you think, would it make more sense to a) support only twitter, or b) support both?

@philippkuehn
Copy link
Author

You made it for GitHub so I would prefer b :)

Another solution would be to give an option to pass a custom regex.

btw I also miss a package for supporting hashtags which would be very similar to this one. But this is out of scope here.

@wooorm
Copy link
Member

wooorm commented Apr 23, 2020

Yah, this project was specifically made for https://github.com/github/opensource.guide, and I’m using it on all our readmes, so typically stuff that renders on GH or like that, so indeed, no twitter handles!

Re b), vaguely worded, but I meant to question whether people would use @foo and @bar together, where the former would refer to a GH user, and the latter to a twitter user, which doesn’t make too much sense to me.

I think passing in a new regex makes sense. And a boolean option for whether to support teams?
Wonder if we should make “presets”: pass in 'github' to get the current regex and teams, pass twitter to get their regex and no teams.

So then, accept a style option, defaulting to 'github', which could be 'github', 'twitter', or an object: {name: /\w+/, teams: false}? Maybe teams could have a better name.

Do you know what the syntax for twitter handles is?

@philippkuehn
Copy link
Author

philippkuehn commented Apr 23, 2020

I'm building a markdown writing app with spell checks etc. So I don't know which kind of mention will may be used. I would love to support just some kind of "generic" mention.

So when adding a style option with 'github', 'twitter' and a regex I have to go with the regex. Maybe we can also allow style: ['github', 'twitter'] but that will make it more complex? Since teams is a GitHub feature I don't think it's useful as an option – it should be part of the GitHub regex.

syntax for twitter handles:

A username can only contain alphanumeric characters (letters A-Z, numbers 0-9) with the exception of underscores, as noted above. Check to make sure your desired username doesn't contain any symbols, dashes, or spaces.

Your username cannot be longer than 15 characters.

@wooorm
Copy link
Member

wooorm commented Apr 23, 2020

So /^[a-z0-9_]{1,15}$/i can work for twitter!

Since teams is a GitHub feature I don't think it's useful as an option – it should be part of the GitHub regex.

Teams unfortunately can’t be matched with a regex, as / is not part of a word, hence an extra option:

if (
valueOf(siblings[offset + 1]) === '/' &&
name.test(valueOf(siblings[offset + 2]))
) {
offset += 2
}


So, in your writing app, what should happen if someone were to use a GH-style mention of @remarkjs/maintainers?

@philippkuehn
Copy link
Author

Ah okay, makes sense.

So, in your writing app, what should happen if someone were to use a GH-style mention of @remarkjs/maintainers?

I want to prevent that retext-spell finds anything within a mention. So @_philippkuehn or @remarkjs/maintainers should’t throw a spell error.

@wooorm wooorm closed this as completed in 641f66f Apr 24, 2020
@wooorm
Copy link
Member

wooorm commented Apr 24, 2020

Teams wasn’t needed! Released in 2.1.0. See docs for more info.

@philippkuehn
Copy link
Author

great! thank you! 🙌

@wooorm wooorm added ⛵️ status/released 🗄 area/interface This affects the public interface 🦋 type/enhancement This is great to have 🧒 semver/minor This is backwards-compatible change and removed 🙉 open/needs-info This needs some more info 🦋 type/enhancement This is great to have labels Jul 23, 2020
@wooorm wooorm added the 💪 phase/solved Post is done label Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🧒 semver/minor This is backwards-compatible change 🦋 type/enhancement This is great to have
Development

No branches or pull requests

2 participants