I run an active Movable Type-driven site where visitors include hyperlinks in their comments using HTML markup like this:

Read more on <a href="http://ekzemplo.com">Ekzemplo</a>

A lot of people don't know HTML, so they paste URLs:

Read more on http://ekzemplo.com

This is less useful and causes presentation problems when a long URL takes up more space than the site's tables can handle, pushing the right margin off the edge.

I needed to turn plain URLs into hyperlinks without messing up existing links in HTML, so I tried Brad Choate's Regex plug-in, which enables regular expressions to process any Movable Type tag's output.

With a lot of trial-and-error and the help of an online regex tester, I used the plug-in's MTRegexDefine tag to define three find-and-replace regular expressions (in Perl syntax):

A global tag attribute, regex, causes these expressions to be used on its output:

<MTCommentBody regex="1">

Plain URLs are converted to hyperlinks with their domain as the linked text. The order of the regular expressions is important; the plugin invokes hideanchor, longurl, and then showanchor in that order.

-- Rogers Cadenhead


I'd like to thank you for the efforts you've put in penning this website. I'm hoping to view the same high-grade blog posts from you later on as well. In fact, your creative writing abilities has inspired me to get my own blog now ;)|


I was curious if you ever thought of changing the structure of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two images. Maybe you could space it out better?|


Hello, the whole thing is going fine here and ofcourse every one is sharing information, that's actually excellent, keep up writing.|


Article writing is also a fun, if you be acquainted with then you can write if not it is difficult to write.|


I'll right away clutch your rss feed as I can't in finding your e-mail subscription hyperlink or newsletter service. Do you've any? Kindly let me know so that I may just subscribe. Thanks.|


Hi i am kavin, its my first occasion to commenting anyplace, when i read this article i thought i could also create comment due to this brilliant paragraph.|


Add a Comment

These HTML tags are permitted: p, b, i, a, and blockquote. A comment may not include more than three links. Participants in this discussion should note the site's moderation policy.