-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
🥔✨ Journal
: Entries
link to their Keywords
#1684
Conversation
Journal
: Entries
link to their Keywords
Journal
: Entries
link to their Keywords
a0a27ab
to
aeb7b84
Compare
text.gsub!(/\#(#{search})/i) do |match| | ||
link_to(match, keyword.location) | ||
end |
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.
What about extracting this into a separate (named) helper. Anytime I encounter a regex I find I spend too much time figuring out what it's trying to do.
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.
I'm not sure what the name would be; or the right seam... If you have more specific suggestions I'd be down to try something.
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.
I pulled out a few small methods with more helpful names, which I think may help? LMK if not.
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.
I like it!
aeb7b84
to
290e8c5
Compare
290e8c5
to
cf3fb70
Compare
end | ||
end | ||
|
||
# We sort the keywords longest to shortest because regex matches groups left-to-right |
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.
Super helpful! ❤️
text | ||
end | ||
|
||
private def replace_keyword(text, keyword) |
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.
Other name suggestions my brain comes up with:
- replace_keywords_with_link
- keywords_to_link
- linkify_keywords
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.
I like linkify_keywords
! Wil try to do that.
Journal
: WritingEntries
journal#2Journal
: BrowsingEntries
journal#4