Autolink URLs in MT Entries

Freshness Warning
This article is over 13 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 fr Firefox ist unspektakulr, aber klasse. Fr 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

  • Google on the desktop Google picks up Picasa, giving them an important foothold on people's PCs.
  • 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.
  • Pitching Bloggers Forget what you learned in your PR classes. Start acting like a human instead of a marketer, and the humans behind the blogs will respond.
  • Writing Realistic Job Descriptions Publish a job listing like this one and you are virtually guaranteeing that you won't get qualified applicants for the position.
  • How not to apply for a job Applying for a job isn't that hard, but it does take some minimal effort and common sense.
  • More of the best »

Recently Read

Get More

Subscribe | Archives

13

Recently

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.
Speaking for Geeks: Your Slides (Dec 17)
Tips and tricks for creating great slides.
Speaking for Geeks: Writing Your Talk (Dec 14)
Don’t wait until the night before the talk to write it. Crazy, I know.
Speaking for Geeks: Tell a Story (Dec 13)
Telling a story keeps your presentation focused, keeps your audience interested, and makes it easier for you to remember your talk.
Speaking for Geeks: Where to speak (Dec 11)
You've got a great idea for a talk. How do you find conferences to submit it to?

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.