Sometimes I feel quite clever only for it to be demonstrated how I might have been overthinking things.

Smokey recently produced a function to automatically convert @-mentions to clickable links for micro.blog users.

His regex pattern is simple and works.

He takes a different approach to my hashtag linking function in that his is applied pre save thus changing the actual post content, whereas mine only impacts the output when viewed.

It's crazy how performing the same action at two different times (save vs display) requires such a difference in complexity of solution.

Note: his pattern doesn't work at display time.

I'm sticking to my method as I've only ever wanted the hashtags to be a feature when viewing the blog itself rather than when distributed via RSS, but it's been a good lesson.

  1. Colin Walker says: #
    Indeed, it’s just surprising how doing the same thing at different points requires something totally different.
  2. PhoneBoy says: #
    I think you're also trying to do a little more as well (auto linking hashtags). It wasn't clear from your post exactly what I needed to add to functions.php where, though. Can you point to more explicit instructions?
  3. smokey says: #
    Your regex is certainly more comprehensive than mine ;-) There are several edge-cases mine doesn't handle (most notably adjacent to HTML markup). I think it's neat how you can have your hashtags only linked on your site (where they make sense). But mostly I like how we're all sharing helpful code snippets and learning from each other here 👍
  4. Colin Walker says: #
    I tried yours against a test post I have in draft and it worked perfectly. The difference between save and display requirements is crazy.

Leave a Reply

Your email address will not be published.