The big regex at doMagicLinks deserves being more thoroughly studied.