Refactor follow prev/next links (supersedes #260)

- Simplified everything.
- Made it more DRY.
- Patterns can include the * and ! wildcards, just like the black list.
- Patterns must match either at the beginning or at the end of the link
  text.
- Patterns don’t match in the middle of words. Works with non-English
  characters too.
  
This PR is based on and included #260.

/cc @zhuochun