Autolink URLs in MT Entries

Freshness Warning
This article is over 14 years old. It's possible that the information you read below isn't current.

One of the things I really hate about reading newspaper Web sites is they often include URLs but don’t link them. So you have to copy and paste to open them (or just rightclick with the right Firefox extension).

I don’t want my site to look like a big, dumb newspaper. So I wrote a filter using Brad’s regex plugin to autolink URLs in entries. It hasn’t been extensively tested but it has worked for a the half-dozen or so entries in the Project X blog.

Install the regex plugin and then add this to the top of your templates…

<MTAddRegex name="autolink">s![> ](http://[^<" ]+)!<a href="$1">$1</a> !g</MTAddRegex>

Then add the attribute regex="autolink" to your MTEntryBody and MTEntry more tags in your templates: <MTEntryBody regex="autolink">.

Trackback from Movalog Sideblog
August 16, 2004 10:32 PM

Autolink URLs in MT Entries

Excerpt: Autolink URLs in MT Entries...

Terrence Wood
August 17, 2004 5:35 PM

I don't have MT installed, but I think this regex will also replace existing links, and should read: s![^">](http://[^<" ]+)! <a href="$1">$1</a> !g

Trackback from Lummaland
August 17, 2004 11:27 PM

Plain Text Links

Excerpt: Die Extension Plain Text Links für Firefox ist unspektakulär, aber klasse. Für all die Websites, insbesondere Online-Ausgaben der Zeitungen, die nicht in der Lage sind, einen URL auch klickbar zu ma...

Adam Kalsey
August 18, 2004 11:38 AM

No, the [> ] in my original regex means that the pattern will only match URLs that immediately follow a > (the end of a tag) or a blank space. So it won't match a URL in an anchor tag.

peter
March 27, 2006 7:26 PM

For me, the regex you supplied only works on the first link immediately after a paragraph tag - and then it mucks up the paragraph tag like so: <p<a href= 'sup with that.

This discussion has been closed.

Follow me on Twitter

Best Of

  • The best of 2006 I wrote a lot of drivel in 2006. Here's the things that are less crappy than the rest.
  • Where do the RSS ad startups fit in? Yahoo's RSS advertising service could spell trouble for pure-play RSS advertising services unless they adapt their business model.
  • The importance of being good Starbucks is pulling CD burning stations from their stores. That says something interesting about their brand.
  • Rounded corners in CSS There lots of ways to create rounded corners with CSS, but they always require lots of complex HTML and CSS. This is simpler.
  • Lock-in is bad T-Mobile thinks they'll get new Hotspot customers with exclusive content and locked-in devices.
  • More of the best »

Recently Read

Get More

Subscribe | Archives

14

Recently

One on One meetings for managers: Frequency and Duration (Nov 28)
How long should your 1:1s be? How often should you run them?
One on One meetings for managers (Nov 26)
A one on one meeting is one of the top ways you can build your managerial leverage
How the Sales organization in a large company slows innovation (Nov 16)
If you have a new innovative product inside a large established company, it can be much harder to reach product market fit than it would be for the same product in a startup.
Networking as an entrepreneur (Oct 23)
Having a network is crazy important. Networking is not.
Stretching your team (Jun 11)
Stretching your team is one of the best ways to improve your output, your team's happiness, and your velocity. But they'll need coaching.
Physical camera shutter for Cisco Spark Board (Jul 6)
A 3d printable design for a camera shutter for a Cisco Spark Board
My Travel Coffee Setup (Jan 20)
What my travel coffee brewing setup looks like, and how you can build your own for under $100.
Turkey Legs (May 30)
Product naming gone awry.

Subscribe to this site's feed.

Elsewhere

Tropo
Voice and communications platforms, including Tropo and Phono. Work.
SacStarts
The Sacramento technology startup community.
Pinewood Freak
Pinewood Derby tips and tricks

Contact

Adam Kalsey

Mobile: 916.600.2497

Email: adam AT kalsey.com

AIM or Skype: akalsey

Resume

PGP Key

©1999-2018 Adam Kalsey.
Content management by Movable Type.