-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
[chore/bugfix] Deinterface text.Formatter, allow underscores in hashtags #2233
Conversation
@@ -1,70 +0,0 @@ | |||
// GoToSocial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stuff has moved into plain.go
@@ -0,0 +1,423 @@ | |||
// GoToSocial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic in here was mostly taken from goldmark_extension.go
. Just tried to make it more consistent.
@@ -0,0 +1,281 @@ | |||
// GoToSocial |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stuff in this file was previously in goldmark_extension.go
but I moved it here to reflect that this stuff is about parsing and not about rendering.
for i, r := range normalized { | ||
if i >= maximumHashtagLength || !util.IsPermittedInHashtag(r) { | ||
ok = false | ||
if r != '_' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents playing silly buggers and making a hashtag like #____________
.
Unfortunately silly hashtags are still possible, so stuff like #a_______________________
is OK.
We might want to fix this up later or make it a bit more nuanced in terms of what it allows, but for now I figured this was OK.
package text | ||
|
||
import "unicode" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved these from the more central util
package and unexported them, since they were only being used in internal/text
.
isPermittedInHashtag(r) | ||
} | ||
|
||
func isPermittedInHashtag(r rune) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the following function is where underscores get excepted. In other words, these are the actual fixes for #2199
Description
This pull request does the following:
text.Formatter
to make the code a bit simpler.internal/text
goldmark and parsing stuff, to make it more consistent and (i hope) more readable!One of the side effects of this is that it's no longer possible to create italicized hashtags
_#LikeThis_
, however they can still be created*#LikeThis*
.closes #2199
Checklist
Please put an x inside each checkbox to indicate that you've read and followed it:
[ ]
->[x]
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
go fmt ./...
andgolangci-lint run
.