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

🥔✨ Journal: Entries link to their Keywords #1684

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

zspencer
Copy link
Member

@zspencer zspencer commented Jul 20, 2023

@zspencer zspencer marked this pull request as draft July 20, 2023 19:38
@zspencer zspencer changed the title Journal: Entries link to their Keywords 🥔✨ Journal: Entries link to their Keywords Jul 20, 2023
@zspencer zspencer added ✨ feature Reduces Client's Burden or Grants them Benefits 🥔 Satisfices It's good enough to use, but not particularly great labels Jul 20, 2023
@zspencer zspencer marked this pull request as ready for review July 20, 2023 19:46
@zspencer zspencer requested review from a team July 20, 2023 19:46
@zspencer zspencer force-pushed the journal/link-to-terms-really branch from a0a27ab to aeb7b84 Compare July 20, 2023 19:50
Comment on lines 18 to 20
text.gsub!(/\#(#{search})/i) do |match|
link_to(match, keyword.location)
end
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it!

Base automatically changed from journal/link-to-terms to main July 20, 2023 20:46
@zspencer zspencer force-pushed the journal/link-to-terms-really branch from aeb7b84 to 290e8c5 Compare July 20, 2023 20:47
@zspencer zspencer force-pushed the journal/link-to-terms-really branch from 290e8c5 to cf3fb70 Compare July 20, 2023 20:47
@zspencer zspencer merged commit 5071b58 into main Jul 20, 2023
@zspencer zspencer deleted the journal/link-to-terms-really branch July 20, 2023 21:21
end
end

# We sort the keywords longest to shortest because regex matches groups left-to-right
Copy link
Contributor

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)
Copy link
Contributor

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

☺️

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature Reduces Client's Burden or Grants them Benefits 🥔 Satisfices It's good enough to use, but not particularly great
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants