AutoLink filters
If you've made new AutoLink filters, please post them in comments wrapped in <pre> or post them in your blog and use trackback. Feel free to request filters, too.
For tutorials and references on using regular expressions in JavaScript, see http://del.icio.us/jesser/regexp+javascript.
Tips for testing filters:
- Use the Edit button in Greasemonkey 0.3.3+. As soon as you save your changes in your text editor, they will apply the next time you load or reload a page.
- Create a test page similar to autolink-test.html. Then you can test each change by saving autolink.user.js in your text editor and reloading the test page.
- Use Thomas Russell's regular expression tool or the JavaScript Environment to test your regular expressions.
May 24th, 2005 at 5:23 am
I didn’t want to match on every 5 digit number for zip, so this will match any 5-4 zip and “statecode zip” would love to see an autolink for full addresses ;)
{ name: "Zip --> Google maps", regexp: /([A-Z]{2} (\d{5}))/g, href: function(match) { return "http://maps.google.com/maps?q=" + digits(match[0]) ; } }, { name: "Zip --> Google maps2", regexp: /(\d{5}-\d{4})/ig, href: function(match) { return "http://maps.google.com/maps?q=" + match[0] ; } },May 24th, 2005 at 5:30 am
I just noticed that my test case for the 5-4 could probably use at a minimum a space before the digits since it fasly triggers on one of your “these are not phone numbers” test…
Perhaps we need an autolink acid test ;)
May 24th, 2005 at 8:10 am
I’m thinking of making AutoLink ignore any matches that are prededed or followed by a number or letter. Individual filters might be able to override this with some kind of flag.
May 24th, 2005 at 8:46 am
I wanted a filter that handled hxxp links, so hacked together this by looking at the already exisiting filters. I have no idea if it is optimal, but it works.
{ name: "Munged text link", regexp: /hxxps?\:\/\/([^"\s\]*[^.,;'">\:\s\)\]\!])/g, href: function(match) { return "http://" + match[1]; } },May 24th, 2005 at 11:03 am
Quick fixes for the ISBN test cases to not link at all.
ISBN –> Amazon
/ISBN( number)?:? \#?((\d(-)?){9}[\dx])(?!\d)/igFixes: ISBN 12345678901
US phone number –> Skype
/((\(\d{3}\)[\s-]?)|(\d{3}(\s|-)))\d{3}[\s-]\d{4}(?!\d)/gFixes: ISBN 123456789-123-12345-1
Basically it does a look ahead to make sure the following isn’t a number.
May 24th, 2005 at 11:53 am
Oh. Perhaps the lookahead for the ISBN should also include – instead of just \d
Failure: Second Edition: 2003 ISBN: 0-13-0444911-3
Success: Second Edition: 2003 ISBN: 0-13-044911-3
/ISBN( number)?:? \#?((\d(-)?){9}[\dx])(?![\d\-])/igMay 24th, 2005 at 1:31 pm
UK Post Codes
{ name: "Post Code", regexp: /[A-Z]{1,2}\d{1,2}[A-Z]{0,1}\s\d[A-Z]{2}/g, href: function(match) { return "http://maps.google.co.uk/maps?q=" + match[0]; } },May 26th, 2005 at 7:40 pm
Reporting a bug:
Cause’s gmail to mess up reply’s and forwarding.
Steps to reproduce:
1: open an email with URLs
2: Hit reply or forward at the bottom
expected: operate normally
what happens: it removes URLs from the email to-be- replied or forwarded and messes things up.
Just thought you might wana know.
May 26th, 2005 at 9:37 pm
WFM with a plaintext email containing a bug number.
June 1st, 2005 at 8:32 pm
There are some sites that do not “linkify” the urls because they want to avoid links being traced back to them…
{ name: "Plain text link", regexp: /https?\:\/\/[^"\s\]*[^.,;'">\:\s\)\]\!]/g, href: function(match) { return "javascript:z=document.open();z.write("");z.close();"; } },Do a similar thing to the munged text (since it is more then likely that the person munged the text to avoid such trace backness)… If there is a better way to hide referers or whatever… please let me know.
June 13th, 2005 at 8:41 am
Bug: textarea truncates…
This happens on autolink, but not on autologin
{put 500 lines of text here}June 13th, 2005 at 8:42 am
erms… ok.. pre doesn’t escape out html…
basicly put 500 lines of text in a textarea, with autolink on it’ll truncate to around 250ish lines