LGF Technical Update
The comment posting code has been greatly improved, with a new URL autolinking routine that works much more reliably than the dated, buggy one we’ve been using for at least three years. It also produces prettier links than the previous autolinker; the title for the link is set to the domain name portion of the linked site, so you can see at a glance where the link will take you. For example, if you paste a link to the New York Times into a comment, the link will be titled “www.nytimes.com”.
If you type in the full HTML code for your link instead of just pasting the URL, the autolinker leaves it alone. This new code also fixes a bug in the previous autolinker, which would mess up the HTML if there were two links in a comment to the same domain name.
I’ve also written some new routines to allow formatted blocks of sample code to be included in a post (not a comment, sorry… although I might allow it if there’s a public outcry). The only thing I’m not sure about is whether the CSS styles that wrap the <PRE> block at our column width will work in all browsers; so I’m going to test this now by posting the new LGF autolinking routines. If it makes the page blow up in your browser, I’m sure you’ll let me know. It looks beautiful in Safari, and OK in Firefox; if there’s a problem I’m sure it will come from Internet Explorer, as always.
This gnarly bunch of regular expressions may come in handy to another PHP programmer or two; they’re based on some code that was posted at the PHP web site under the documentation for the preg_replace() function, with lizardoid modifications to make things more sleek. To use the function, simply call MakeLinks($text), with the $text variable set to the chunk of text you want to scan for URLs. (The PrettyLink() function is called internally by MakeLinks().)
Here are the CSS styles that are supposed to make this PRE-formatted area wrap to a width of 520 pixels in a perfect world:
UPDATE at 11/27/06 9:33:54 am:
Since Microsoft Internet Explorer, the bane of my existence, refuses to play nice with my PRE-formatted blocks, I’ve now changed the post generation module to include a browser sniffer (PEAR’s Net_UserAgent_Detect) so that users of IE will see the code fragments enclosed safely in HTML <textarea> tags. I don’t like using sniffers, but it’s the only solution for the IE nightmare.
Firefox is still being a bit of a pest in the issue of PRE wrapping. The text is wrapping, but not where it’s supposed to wrap. It’s not as much of a problem as IE, because it doesn’t cause the middle column to expand; the text simply runs over the right column.



